Node: parentNode プロパティ
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.
parentNode
は Node
インターフェイスの読み取り専用プロパティで、 DOM ツリー内の特定のノードの親ノードを返します。
Document
および DocumentFragment
ノードには親が付くことはないので、 parentNode
は常に null
になります。
ノードが生成されてからツリーに割り当てられていない場合も null
を返します。
値
現在のノードの親に当たる Node
です。要素の親になるのは Element
ノード、 Document
ノード、 DocumentFragment
ノードの何れかです。
例
js
if (node.parentNode) {
// ノードがツリーの中にある場合は、ツリーから取り除く
node.parentNode.removeChild(node);
}
仕様書
Specification |
---|
DOM # ref-for-dom-node-parentnode① |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
parentNode |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.