Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM previousSibling Property

HTML DOM previousSibling Property

Element Object Reference Element object

Example

Returns the node immediately preceding a given node:

document.getElementById("item2").previousSibling;

Try it »


Definition and Usage

The previousSibling property returns the node immediately preceding a given node (at the same tree level)

The node is returned as a node object.

**Note:** If this node does not exist, the property returns null.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the previousSibling property


Syntax

node

.previousSibling

Technical Details

Return Value: The node immediately preceding a given node (at the same tree level), returned as a node object
DOM version Core Level 1 Node Object

Element Object Reference Element object