Mbrouwer88 Mbrouwer88 - 1 year ago 92
HTML Question

javascript nested onclick

I have this code:

<td onclick="Test()">
<img src="test.jpg" onclick="Test2(); return false;"><br>
Rest of the cell with some text.

When I click the image, Test() is also fired because I am also clicking the table cell. How to provent this? If I click on the image, I want test2() to fire, if I click somewhere else in the table cell, test() should be fired.

Edit: Even with return false, Test() is still fired(testing in Chrome)!

Answer Source

Short answer:

<img src="test.jpg" onclick="Test2(); return false;">

Long answer:

Event Order - http://www.quirksmode.org/js/events_order.html

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download