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

HTML DOM previousElementSibling property

HTML DOM previousElementSibling property

Element Object Reference Element object

Example

Return the HTML content of the previous list option:

var

x

=

document

.

getElementById

(

"

item2

"

)

.

previousElementSibling

.

innerHTML

;

Try it »


Definition and Usage

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

The difference between the previousSibling property and the previousElementSibling property:

The previousElementSibling property is read-only.

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

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


Browser support

property
previousElementSibling 2.0 9.0 3.5 4.0 10.0

Syntax

node.previousElementSibling 

Technical Details

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

Element Object Reference Element object