TreeWalker.previousSibling()
The TreeWalker.previousSibling()
method moves the current
Node
to its previous 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.previousSibling();
Example
var treeWalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{ acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
false
);
var node = treeWalker.previousSibling(); // returns null as there is no previous sibling
Specifications
Specification |
---|
DOM Standard # dom-treewalker-previoussibling |
Browser compatibility
BCD tables only load in the browser
See also
- The
TreeWalker
interface it belongs to.