Node: parentElement プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

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

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

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

仕様書

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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
parentElement

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
See implementation notes.

関連情報