Node: parentElement プロパティ

parentElementNode インターフェイスの読み取り専用プロパティで、この DOM ノードの親である要素 (Element) を返します。このノードに親ノードがないか、親が DOM の Element でない場合は null を返します。

現在のノードの親ノードである Element を返します。そのようなものがない場合は null を返します。

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

仕様書

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

ブラウザーの互換性

BCD tables only load in the browser

関連情報