...

View Full Version : element.addEventListener in nested div problem



ogbi-web_kenobi
12-06-2010, 02:23 AM
function offPar(){
alert(this.offsetParent.id);
}

function init(){
var mine = document.getElementById("mid");
var other = document.getElementById("inner");

mine.addEventListener("click", offPar, false);
other.addEventlistener("click", offPar, false);

}

window.addEventListener('load', init, false);

HTML :
<div id = "content">

<div id = "mid">
<div id = "inner">
<p class = "par">
</p>
</div>
</div>

</div>


I can add an event listener to the #mid div but I can't to the #inner div.
Anyone now why this is? Sorry I can't provide more info. That's all I Know!

TTFN
John

DrDOS
12-06-2010, 02:27 AM
It's because javascript is case sensitive and this: other.addEventlistener should be this: other.addEventListener.

ogbi-web_kenobi
12-06-2010, 03:01 AM
bows head in shame. opps! Thanks for proof-reading that for me... uh ... I'll just leave now.

TTFN
John



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum