Last major update on 29 June 2010.
If you'd like to have some practical examples of what you can do with the W3C DOM, read my book ppk on JavaScript, especially chapter 8.
These compatibility tables detail support for the W3C DOM Traversal in all modern browsers.
The purpose of these properties is to ignore non-element nodes. Therefore they’ll always return the first, next, previous, or last element node.
Selector | IE 5.5 | IE 6 | IE 7 | IE8 | IE9 pr3 | FF 3.0 | FF 3.5 | FF 3.6 | Saf 4.0 Win | Saf 5.0 Win | Chrome 5 | Opera 10.10 | Opera 10.53 | Konqueror 4.x | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
childElementCount
The number of element children
Test page |
No | Yes | No | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||
x.childElementCount |
||||||||||||||||||||||||
firstElementChild
The first child that is an element node
Test page |
No | Yes | No | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||
x.firstElementChild |
||||||||||||||||||||||||
lastElementChild
The last child that is an element node
Test page |
No | Yes | No | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||
x.lastElementChild |
||||||||||||||||||||||||
nextElementSibling
The next element node sibling
Test page |
No | Yes | No | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||
x.nextElementSibling |
||||||||||||||||||||||||
previousElementSibling
The previous element node sibling
Test page |
No | Yes | No | Yes | Yes | Yes | Yes | To be tested | ||||||||||||||||
x.previousElementSibling |