Node.parentElement

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
DOM
The 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.

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
parentElementChrome Full support 1Edge Full support 12Firefox Full support 9IE Full support 9
Notes
Full support 9
Notes
Notes Only supported on Element.
Opera Full support 7Safari Full support 1.1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 9Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0

Legend

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

See also