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
Mozilla Developer Network : [TreeWalker.nextSibling Article]
Microsoft Developer Network: [nextSibling Method Article]