TreeWalker: previousNode() method - Web APIs | MDN
Syntax
Parameters
None.
Return value
A Node object or null.
Examples
js
const treeWalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{
acceptNode(node) {
return NodeFilter.FILTER_ACCEPT;
},
},
false,
);
const node = treeWalker.previousNode(); // returns null as there is no parent
Specifications
| Specification |
|---|
| DOM # dom-treewalker-previousnode |
Browser compatibility
See also
- The
TreeWalkerinterface it belongs to.