Topic: Need help - Javscript onclick event issue (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: you tell me |
posted 04-05-2008 15:08
Hi guys need some help here pronto. I have a div whcih nests some other divs like this code: <div id="container" onclick="dosomething()"> <div id="column01">....</div> <div id="column02">....</div> <div id="column03">....</div> </div>
|
Paranoid (IV) Inmate From: Norway |
posted 04-05-2008 17:13
You have to check that the element that fired the event ( event.target in the DOM2 standard, event.srcElement in non standards compliant browsers ) is element to which the event handler is attached ( event.currentTarget ). code: onload = function() { document.getElementById('container').onclick = function( event ) { var event = event||window.event, src = event.target||event.srcElement; if( src==event.currentTarget ) { // hooray! } } } And forget about putting event listeneres inside the markup. |