Web/API/Node/parentElement

From Get docs
< Web/API‎ | Node


The Node.parentElement read-only property returns the DOM node's parent Element, or null if the node either has no parent, or its parent isn't a DOM Element.

Syntax

parentElement = node.parentElement

parentElement is the parent element of the current node. This is always a DOM Element object, or null.

Example

if (node.parentElement) {
    node.parentElement.style.color = "red";
}

Specifications

Specification Status Comment
DOMThe definition of 'parentElement' in that specification. Living Standard Initial definition.

Browser compatibility

On some browsers, the parentElement property is only defined on nodes that are themselves an Element. In particular, it is not defined on text nodes.

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
parentElement Chrome

Full support 1

Edge

Full support 12

Firefox

Full support 9

IE Full support 9

Notes'

Full support 9

Notes'

Notes' Only supported on Element.

Opera

Full support 7

Safari

Full support 1.1

WebView Android

Full support 1

Chrome Android

Full support 18

Firefox Android

Full support 9

Opera Android

Full support 10.1

Safari iOS

Full support 1

Samsung Internet Android

Full support 1.0

Legend

Full support  
Full support
See implementation notes.'
See implementation notes.


See also