TreeWalker.nextSibling()
The TreeWalker.nextSibling()
method moves the current
Node
to its next sibling, if any, and returns the found sibling. If there
is no such node, return null
and the current node is not changed.
Syntax
node = treeWalker.nextSibling();
Example
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
Specifications
Specification |
---|
DOM Standard # dom-treewalker-nextsibling |
Browser compatibility
BCD tables only load in the browser
See also
- The
TreeWalker
interface it belongs to.