Package | elementtraversal |
Interface | public interface ElementTraversal |
Implementors | Element |
All browser compatibility information was obtained via Quirksmode.
See also
Property | Defined By | ||
---|---|---|---|
Element Traversal childElementCount : Number [read-only]
Returns the current number of element nodes that are children of this
element. | ElementTraversal | ||
Element Traversal firstElementChild : Element [read-only]
Returns the first child element node of this element. | ElementTraversal | ||
Element Traversal lastElementChild : Element [read-only]
Returns the last child element node of this element. | ElementTraversal | ||
Element Traversal nextElementSibling : Element [read-only]
Returns the next sibling element node of this element. | ElementTraversal | ||
Element Traversal previousElementSibling : Element [read-only]
Returns the previous sibling element node of this element. | ElementTraversal |
Element Traversal childElementCount | property |
childElementCount:Number
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Returns the current number of element nodes that are children of this element. 0 if this element has no child nodes that are of nodeType 1.
public function get childElementCount():Number
See also
Element Traversal firstElementChild | property |
firstElementChild:Element
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Returns the first child element node of this element. null if this element has no child elements.
public function get firstElementChild():Element
See also
<p id="para-01"> <span>First span</span> </p> <script type="text/javascript"> var p01 = document.getElementById('para-01'); alert(p01.firstElementChild.nodeName); </script>
Element Traversal lastElementChild | property |
lastElementChild:Element
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Returns the last child element node of this element. null if this element has no child elements.
public function get lastElementChild():Element
See also
<p id="para-01"> <span>First span</span> <b>bold</b> </p> <script type="text/javascript"> var p01 = document.getElementById('para-01'); alert(p01.lastElementChild.nodeName); </script>
Element Traversal nextElementSibling | property |
nextElementSibling:Element
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Returns the next sibling element node of this element. null if this element has no element sibling nodes that come after this one in the document tree.
public function get nextElementSibling():Element
See also
<div id="div-01">Here is div-01</div> <div id="div-02">Here is div-02</div> <script type="text/javascript"> var el = document.getElementById('div-01').nextElementSibling; document.write('<p>Siblings of div-01</p><ol>'); while (el) { document.write('<li>' + el.nodeName + '</li>'); el = el.nextElementSibling; } document.write('</ol>'); </script>
This example outputs the following into the page when it loads:
Siblings of div-01
Element Traversal previousElementSibling | property |
previousElementSibling:Element
[read-only] Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Returns the previous sibling element node of this element. null if this element has no element sibling nodes that come before this one in the document tree.
public function get previousElementSibling():Element
See also
<div id="div-01">Here is div-01</div> <div id="div-02">Here is div-02</div> <li>This is a list item</li> <li>This is another list item</li> <div id="div-03">Here is div-03</div> <script type="text/javascript"> var el = document.getElementById('div-03').previousElementSibling; document.write('<p>Siblings of div-03</p><ol>'); while (el) { document.write('<li>' + el.nodeName + '</li>'); el = el.previousElementSibling; } document.write('</ol>'); </script>
This example outputs the following into the page when it loads:
Siblings of div-03