parentNode
Summary
Retrieves the parent object in the document hierarchy relative to the current node and updates currentNode.
Method of dom/TreeWalkerdom/TreeWalker
Syntax
var node = treewalker.parentNode();
Return Value
Returns an object of type DOM NodeDOM Node
Object that receives the 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
);
var node = treewalker.parentNode(); // returns null as there is no parent
Notes
Remarks
parentNode sets the currentNode to the returned node.
If no such node exists, or if it is above the TreeWalker's root node, returns null and the current node is not changed.
Syntax
Standards information
Related specifications
- DOM
- Living Standard
Attributions
Mozilla Developer Network : [TreeWalker.parentNode Article
Microsoft Developer Network: [parentNode Method Article]