Easy Tutorial
❮ Met Node Replacechild Prop Body Text ❯

HTML DOM previousElementSibling Property

Element Object

Example

Return the HTML content of the previous list item:

var x = document.getElementById("item2").previousElementSibling.innerHTML;

Definition and Usage

The previousElementSibling property returns the previous sibling element of the specified element (the previous element in the same tree level).

Differences between previousSibling and previousElementSibling properties:

The previousElementSibling property is read-only.

Tip: Use the nextElementSibling property to return the next sibling element of the specified element.

Tip: Use the children property to return any child elements of the specified element.


Browser Support

Property Chrome IE Firefox Safari Opera
previousElementSibling 2.0 9.0 3.5 4.0 10.0

Syntax

node.previousElementSibling

Technical Details

Return Value: Node object, representing the previous sibling element, or null if there is no previous sibling element.
DOM Version DOM 3
--- ---

Element Object

❮ Met Node Replacechild Prop Body Text ❯