HTML DOM Element parentNode
Example
Get the node name of the parent node of "myLI":
Click on an element (<span>) to hide its parent:
<span onclick="this.parentNode.style.display = 'none';">x</span>
</div>
Description
TheparentNode property returns the parent node of an element or node.
TheparentNode property is read-only.
See Also:
HTML Nodes vs Elements
In theHTML DOM (Document Object Model), an HTML document is a collection of nodes with (or without) child nodes.
Nodes are element nodes, text nodes, and comment nodes.
Whitespace between elements are also text nodes.
Elements are only element nodes.
childNodes vs children
childNodes returns childnodes (element nodes, text nodes, and comment nodes).
children returns childelements (not text and comment nodes).
Siblings vs Element Siblings
Siblings are "brothers" and "sisters".
Siblings are nodes with the same parent (in the samechildNodes list).
Element Siblings are elements with the same parent (in the samechildren list).
Syntax
Return Value
| Type | Description |
| Node | The parent node.null if the node has no parent. |
Browser Support
element.parentnode is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera | IE |
| Yes | Yes | Yes | Yes | Yes | 9-11 |

