TOC PREV NEXT INDEX

domref



getElementsByTagName


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

Syntax

elements = document.getElementsByTagName(Name)
 

Parameters

elements is a nodeList of elements.

tagName is a string representing the name of the elements.

Example

// check the alignment on a number of tables
 
tables = document.getElementsByTagName("table");
 
dump("no. of tables: " + tables.length);
 
for (var i = 0; i < tables.length; i++) {
 
   dump(tables[i].alignment);
 
}
 

Notes

Another very useful feature of DOM programming is the getElementsByTagName() method, which returns a nodeList of all the elements with the given name.

Specification

getElementsByTagName
 


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