title | short-title | slug | page-type | browser-compat |
---|---|---|---|---|
TreeWalker: currentNode property |
currentNode |
Web/API/TreeWalker/currentNode |
web-api-instance-property |
api.TreeWalker.currentNode |
{{ APIRef("DOM") }}
The TreeWalker.currentNode
property represents the
{{domxref("Node")}} which the {{domxref("TreeWalker")}} is currently pointing at.
A {{domxref("Node")}}.
const treeWalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{
acceptNode(node) {
return NodeFilter.FILTER_ACCEPT;
},
},
);
root = treeWalker.currentNode; // the root element as it is the first element!
{{Specifications}}
{{Compat}}
- The {{domxref("TreeWalker")}} interface.