This is my current code:
function tableClick(event){
$('#table').click(function(event){
alert(event.target.id);
});
}
<table id="table">
<tr>
<td id="td1" onclick="tableClick(this)">
1
</td>
</tr>
<tr>
<td id="td2" onclick="tableClick(this)">
2
</td>
</tr>
</table>
What I don't understand is why it pops up the alert window one more time than last. How can I fix this? Thanks in advance.