TOC PREV NEXT INDEX

domref



getElementsByName


Returns a list of elements of a given name in the document.

Syntax

elements = document.getElementsByName(name)
 

Parameters

elements is a nodeList of elements.

name is a string representing the value of the name attribute on the element.

Example

// return some of the divs
 
<div name="up">200</div>
 
<div name="up">145</div>
 
<div name="down">146</div>
 
<div name="other">178</div>
 

 
up_divs = document.getElementsByName("up");
 
dump(up_divs.item(0).tagName); // returns "div"
 

Notes

getElementsByName() returns a nodeList of all the elements with a given value for the name attribute. Unlike getElementsByTagName, which takes the name of the element itself, this method only works for elements for which name attributes have been explicitly given.

Specification

getElementsByName
 


Netscape Communications
http://developer.netscape.com
TOC PREV NEXT INDEX