HTML DOM parentElement Property

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP







<!--
main_leaderboard, all: [728,90][970,90][320,50][468,60]
-->




HTML DOM parentElement Property


Element Object




Example


Get the node name of the parent element of a <li> element:



var x = document.getElementById("myLI").parentElement.nodeName;

<!--

The result of x will be:


UL
-->
Try it Yourself »

More "Try it Yourself" examples below.



Definition and Usage


The parentElement property returns the parent element of the specified
element.


The difference between parentElement and parentNode, is that parentElement
returns null if the parent node is not an element node:



document.body.parentNode; // Returns the <html> element
document.body.parentElement; // Returns the <html> element

document.documentElement.parentNode; // Returns the Document node
document.documentElement.parentElement; // Returns null (<html> does not have a parent ELEMENT node)



In most cases, it does not matter which property you use, however, parentNode
is probably the most popular.


This property is read-only.



Browser Support


The numbers in the table specify the first browser version that fully supports the property.














Property
parentElement 1.0 Yes 9.0 Yes Yes




<!--
mid_content, all: [300,250][336,280][728,90][970,250][970,90][320,50][468,60]
-->




Syntax



node.parentElement

Technical Details






Return Value: An Element object, representing the parent element node of a node, or null if the node has no parent
DOM Version DOM Level 4 Element Object

More Examples



Example


Click on an element (<span>) to hide its parent element (<div>):



<div>
  <span onclick="this.parentElement.style.display = 'none';">x</span>
</div>

Try it Yourself »


Element Object


Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)