Here is a JavaScript code snippet I've been working on:
<div>
<tr onClick="click1()">
<td>
click 1
</td>
<td onClick="click2()">
click 2
</td>
</tr>
</div>
function click1() {
alert(1);
}
function click2() {
alert(2);
}
<table border="1">
<tr onClick="click1()">
<td>
click 1
</td>
<td onClick="click2()">
click 2
</td>
</tr>
</table>
If I click 'click 1', the click1()
function is called as expected. However, if I click 'click 2', both click1()
and click2()
functions are triggered.
Question
Is there a way for the click event on 'click 2' to only execute the click2()
function without triggering the click1()
function? Please advise.