English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
parentElementRead-only property returns the parent element of the specified element.
If the specified element has no parent element, this property returnsnull.
element.parentElement
var x = document.querySelector("#para").parentElement.nodeName;Test See‹/›
parentElement property is fully supported by all browsers:
Property | |||||
parentElement | Yes | Yes | Yes | Yes | Yes |
Return Value: | An Element object representing the parent element of the specified element; if the element has no parent element, it isnull |
---|---|
DOM Version: | DOM 2Level |
Click the <p> element to hide its parent element (<div>):
<div> <p onclick="this.parentElement.style.display='none';">Click me</p> </div>Test See‹/›
HTML DOM Reference:children property