This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

nextSibling

Summary

Retrieves the next sibling of the current node in the filtered TreeWalker hierarchy and updates currentNode.

Method of dom/TreeWalkerdom/TreeWalker

Syntax

var node = treewalker.nextSibling();

Return Value

Returns an object of type DOM NodeDOM Node

Object that receives the next child of a parent node in the filtered TreeWalker hierarchy.

Examples

var treewalker = document.createTreeWalker(
    document.body,
    NodeFilter.SHOW_ELEMENT,
    { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
    false
);
treewalker.firstChild();
var node = treewalker.nextSibling(); // returns null if the first child of the root element has no sibling

Notes

Remarks

nextSibling sets the currentNode to the returned node. It returns null if there are no more child nodes.

Syntax

Standards information

Related specifications

DOM
Living Standard

Attributions