nextSibling (W3C DOM Core property)
| Version | Depr. | Static | Read-only |
|---|---|---|---|
| DOM1 | No | No | Yes |
| IE5.5+ | FF1.5+ | SA1.3+ | OP9+ |
|---|---|---|---|
| Full | Full | Full | Full |
Example
var sibling = node.nextSibling;
In the example above, if node has a sibling immediately
after it (a node of any type, which shares its parent with
node), the sibling variable will be
a reference to that node; otherwise it will be
null.
So in the following HTML example, the
second li element is the
nextSibling of the first, but has no
nextSibling of its own:
<h2>Shopping list</h2> <ul> <li>Chocolate</li> <li>More chocolate</li> </ul>
Actually this example is idealized, and in some browsers the second
li element may not in fact be the
nextSibling of the first; that's because some
browsers count intermediate whitespace as text nodes, and would
therefore consider the nextSibling to be the
whitespace between the </li> and
<li> tags.
For more about this behavior please see DOM Core.
Description
The node immediately after
this node (ie. both nodes have the same parent and are next to each other
in its childNodes collection), or
null if there is no such node.
This property is readonly.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.5 | 2.0 | 3.0 | 1.3 | 2.0 | 3.0 | 9.0 | 9.5 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
No known issues.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.