I have a html code like below
<tbody>
<tr id="info">
<td class="name">Joe</td>
<td class="surname">White</td>
<td class="age">25</td>
</tr>
</tbody>
and there is a jQuery code like this:
$("tr#info").click(function() { // function_tr
$(this).css("background-color","yellow");
});
$("tr#info td").click(function() { // function_td
$(this).css("font-weight","bold");
});
When I click on the td, function_td works fine but function_tr also works.
How to do prevent function_tr?
You need to use event.stopPropagation()