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
.
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
.
An Element
that is the parent element of the current node, or null
if there isn't one.
js
if (node.parentElement) { node.parentElement.style.color = "red"; }
Specification |
---|
DOM Standard # ref-for-dom-node-parentelement① |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
parentElement |
1 | 12 | 9 | 8Only supported onElement . |
7Before Opera 15, this feature was only supported onElement . |
1.1 | 4.4 | 18 | 9 | 10.1Before Opera Android 14, this feature was only supported onElement . |
1 | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement