English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
node.parentNode
var x = document.querySelector("#para").parentNode.nodeName;Test and See‹/›
All browsers fully support the parentNode property:
Property | |||||
parentNode | Yes | Yes | Yes | Yes | Yes |
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 |
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‹/›
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