English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM parentNode attribute

HTML DOM Element Object

parentNodeA read-only property returns the parent node of the specified node as a node object.

If the specified node has no parent node, this property returnsnull.

Syntax:

node.parentNode
var x = document.querySelector("#para").parentNode.nodeName;
Test and See‹/›

Browser Compatibility

All browsers fully support the parentNode property:

Property
parentNodeYesYesYesYesYes

Technical Details

Return Value:A Node object representing the parent node of the specified node; if the node has no parent node, it isnull
DOM Version:DOM Level1

More Examples

Click the <p> element to hide its parent node (<div>):

<div>
   <p onclick="this.parentNode.style.display=&"39;none';">Click me</p>
</div>
Test and See‹/›

Related References

HTML DOM Reference:node.childNodes property

HTML DOM Reference:node.firstChild property

HTML DOM Reference:node.lastChild property

HTML DOM Reference:node.nextSibling property

HTML DOM Reference:node.previousSibling property

HTML DOM Reference:node.nodeName property

HTML DOM Element Object