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

HTML DOM parentElement property

HTML DOM Element Object

parentElementRead-only property returns the parent element of the specified element.

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

Syntax:

element.parentElement
var x = document.querySelector("#para").parentElement.nodeName;
Test See‹/›

Browser Compatibility

parentElement property is fully supported by all browsers:

Property
parentElementYesYesYesYesYes

Technical Details

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

More Examples

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

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

Related References

HTML DOM Reference:children property

HTML DOM Element Object