This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

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