Home | Top | Free Ajax Editor | JavaScript Editor | ![]() | Get Advanced JavaScript and Ajax Editor, Validator and Debugger! 1st JavaScript Editor. |
Retrieves a collection of objects based on the specified element name.
Syntax
collObjects = object .getElementsByTagName( sTagName )Parameters
sTagName | Required. String that specifies the name of an element. |
Return Value
Returns a collection of objects with the specified element name.
Remarks
The getElementsByTagName method is equivalent to using the tags method on the all collection. For example, the following code shows how to retrieve a collection of div elements from the body element, first using the Dynamic HTML (DHTML) Object Model and then the Document Object Model (DOM).
When you use the getElementsByTagName method, all child and nested child elements with the specified tag name are returned. For example, all of the SPAN elements in the following example would be returned by the getElementsByTagName method.
<SCRIPT> var aSpans = oDiv. getElementsByTagName ("SPAN"); </SCRIPT>
<DIV id="oDiv">
<SPAN>Immediate Child <DIV> <SPAN>Child of Child DIV</SPAN> </DIV> </SPAN>
</DIV>
The following example uses the getElementsByTagName method to return the children of a ul element based on the selected li element.
<SCRIPT>
Standards Information
This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
Applies To
|
A , ACRONYM , ADDRESS , APPLET , AREA , B , BASE , BASEFONT , BDO , BGSOUND , BIG , BLOCKQUOTE , BODY , BR , BUTTON , CAPTION , CENTER , CITE , CODE , COL , COLGROUP , CUSTOM , DD , DEL , DFN , DIR , DIV , DL , document , DT , EM , EMBED , FIELDSET , FONT , FORM , FRAME , FRAMESET , HEAD , hn , HR , HTML , I , IFRAME , IMG , INS , KBD , LABEL , LEGEND , LI , LINK , LISTING , MAP , MARQUEE , MENU , OL , P , PLAINTEXT , PRE , Q , S , SAMP , SCRIPT , SELECT , SMALL , SPAN , STRIKE , STRONG , SUB , SUP , TABLE , TBODY , TD , TEXTAREA , TFOOT , TH , THEAD , TITLE , TR , TT , U , UL , VAR , XMP |
Home | Top | Free Ajax Editor | JavaScript Editor | ![]() | Get Advanced JavaScript and Ajax Editor, Validator and Debugger! 1st JavaScript Editor. |