I have simple table with check box. When it is checked – i need to change color of row.
<tr height="35">
<td><input type="checkbox" ></td>
<td>Name</td>
<td>Surname</td>
</tr>
At the moment i do it with
jQuery('input[type="checkbox"]').click(function(){
jQuery(this).parent().parent().css('background-color', 'red');
});
But i think the .parent().parent() is not a good idea… And also is some way to toggle background? Maybe somehow on change ant after is checked or not?
You can use
closest()instead: