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

BCD tables only load in the browser

See also