I have nested event listeners. Exactly they are
<tr onclick="function1();">
<td>....</td>
<td onclick="function2();">....</td>
</tr>
When Second Cell is clicked, only function2() should be called and not function1(). Is there any way to do this?
I have nested event listeners. Exactly they are
<tr onclick="function1();">
<td>....</td>
<td onclick="function2();">....</td>
</tr>
When Second Cell is clicked, only function2() should be called and not function1(). Is there any way to do this?
Pass event object in the function and call stopPropagation to stop event propogation.
<tr onclick="return function1(e);">
<td>First Td....</td>
<td onclick="return function2();">second td....</td>
</tr>
function function2(e)
{
//your statements.
alert("function2");
e.stopPropagation();
}
The event can be stopped using event.stopPropagation
function(e) {
var event = e || window.event;
event.stopPropagation();
}
See the answer here for more discussion: How to stop event propagation with inline onclick attribute?