ZVON > References > DOM2 Reference

getElementsByTagName (method )

Owning interface and usage:  
Element.getElementsByTagName(name)

Member of these other interfaces:  
none

Description:  
Returns a NodeList containing all Elements with the given tag name in the same order as they appear in the source document.

Parameters:  
DOMString name  -  The name of the tag to match on. The special value "*" matches all tags.

Returns:  
NodeList -  A list of matching Element nodes.

Exceptions:  
none


Example:
Text in the first DIV.
Some text in the second DIV.
Some text and element in the third DIV.
We can try another elements. It will be much more interesting.
Text in the last DIV.
Source:
   <div id="doc">
     <div>
       Text in the first DIV.
     </div>
     <div id="DDD" class="secondClass">
       Some text in the second DIV.
     </div>
     <div class="thirdClass">
       Some text and <span id="SSS">element</span> in the third DIV.
     </div>
     <div class="fourthClass">
       We can try <i>another elements</i>.
       It will be much more <b>interesting</b>.
     </div>
     <div>
       Text in the last DIV.
     </div>
   </div>
     
JavaScript:
  var main = document.getElementById('doc');
  var collection = main.getElementsByTagName('div');
  var output1 = collection.length;
  var output2 = collection[0].firstChild.nodeValue;
Output:
desired your browser
output1: 5
output2: Text in the first DIV.