mercredi 16 mars 2016

How to make entire row + checkbox itself click and unclick when I click inside the table row?

I have a table

<tr>
    <td><input name="service_id[]" value="17" type="checkbox"></td>
    <td class="right">$175.00</td>
    <td>add 0 days to delivery</td>
</tr>

And jQuery

$('#tableSelect tr').click(function() {
    if ($(this).find('td input:checkbox').prop('checked') == true)
        $(this).find('td input:checkbox').prop('checked', false);
    else    
        $(this).find('td input:checkbox').prop('checked', true);
});

My goal is to have the checkbox click ON and OFF as I click on anywhere in the table row.

However what I get is I can click anywhere on the table row to click and unclick, but when I click inside the checkbox itself, it does not register my click.

How can I make entire row + checkbox itself click and unclick when I click anywhere inside the entire table row, including entire the checkbox itself?




Aucun commentaire:

Enregistrer un commentaire