Click <tr> to check a checkbox
I'd like to be able to click anywhere on the table row and have the checkbox be 'checked'. I'm a complete beginner at jQuery. This is actually the reason why I'm starting to learn it!
The HTML:
-
<table>
<tr>
<td><input type="checkbox" /></td>
<td>Name</td>
<td>Email</td>
</tr>
</table>
The jQuery:
-
$("input:checkbox").click(function(){
if($(this).attr('checked') == 'checked'){
$(this).parents("tr").addClass('ready');
}
else{
$(this).parents("tr").removeClass('ready');
}
});
This isn't working, however, as I can't get that class to attach to the table row.
Thanks for any help!