Node: parentElement property

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

Value

An Element that is the parent element of the current node, or null if there isn't one.

Example

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

Specifications

Specification
DOM Standard
# ref-for-dom-node-parentelement①

Browser compatibility

desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
parentElement

See also