HTML DOM nextElementSiblingProperty

元素对象参考手册Element Object

Example

Return the HTML content of the next list option:

var x = document.getElementById("item1").nextElementSibling.innerHTML;

Try it Yourself »

Definition and Usage

The nextElementSibling property returns the next sibling element after the specified element (the next element node in the same node tree level).

The difference between the nextSibling property and the nextElementSibling property:

  • The nextSibling property returns sibling nodes after the element node (including text nodes and comment nodes);
  • The nextElementSibling property only returns sibling element nodes after the element node (excluding text nodes and comment nodes);

The nextElementSibling property is read-only.

Tip:Use the previousElementSiblingproperty to return the previous element of the specified element.

Tip:Use thechildrenproperty to return any child element of the specified element.


Browser Support

Property
nextElementSibling 2.0 9.0 3.5 4.0 10.0

Syntax

node.nextElementSibling

Technical Details

Return value: A Node object, representing the next sibling element of the element, or null if there is no next sibling element.
DOM Version DOM 3


元素对象参考手册Element Object

Other Extensions