Menu
Is there any way to find the parent element of an element in HTML with javascript?
Let’s say I have this HTML :
[code=html]
<div>
<div onClick=”alert(this.parentElement.innerHTML)”>Blah blah</div>
</div>
…this, upon clicking the div should alert “<div onClick=”alert(this.parentElement.innerHTML)”>Blah blah</div>”. Now, the parentElement property obviously doesn’t exist, but is there any such thing?
Of course I can do this myself pretty easy, but I’m asking if there’s a more simple solution.