Node.parentElement

Sie lesen die englische Version dieses Inhalts, da für dieses Gebietsschema noch keine Übersetzung vorhanden ist. Helfen Sie uns, diesen Artikel zu übersetzen!

The Node.parentElement read-only property returns the DOM node's parent Element, or null if the node either has no parent, or its parent isn't a DOM Element.

Syntax

parentElement = node.parentElement

parentElement is the parent element of the current node. This is always a DOM Element object, or null.

Example

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

Specifcications

Specification Status Comment
DOM
The definition of 'parentElement' in that specification.
Living Standard Initial definition.

Browser compatibility

On some browsers, the parentElement property is only defined on nodes that are themselves an Element. In particular, it is not defined on text nodes.

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
parentElementChrome Full support YesEdge Full support 12Firefox Full support 9IE Full support Yes
Notes
Full support Yes
Notes
Notes Only supported on Element.
Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 9Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
See implementation notes.
See implementation notes.

See also