previousSibling
Summary
Retrieves the previous sibling of the current node in the filtered TreeWalker hierarchy and updates currentNode.
Method of dom/TreeWalkerdom/TreeWalker
Syntax
var node = treewalker.previousSibling();
Return Value
Returns an object of type DOM NodeDOM Node
.Object that receives the previous 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
);
var node = treewalker.previousSibling(); // returns null as there is no previous sibiling
Notes
Remarks
previousSibling 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.previousSibling Article]
Microsoft Developer Network: [previousSibling Method Article]