JSFiddle - React, Tailwind, and code Playground

by cuzzea

HTML

<table border="1">
<tr>
    <td id='no_label'>
        <input type="checkbox" /> asdasdasdasdasdasd
    </td>
    <td> asd asd as da</td>
</tr><tr>
    <td>
        <input type="checkbox"/> asdasdasdasdasdasd</label>
    </td>
    <td> asd asd as da</td>
</tr>
</table>

CSS

tr{
    background-color:white;
}
tr.selected{
    background-color:grey;
}

JavaScript

function checkCheckbox(checked,tr,checkbox){
    console.log(tr)
    checkbox.attr('checked',checked);
    tr.removeClass('selected');
    if(checked) tr.addClass('selected')
}
    
    
    $('tr').live('click',function(e){
        checkCheckbox(!$(this).hasClass('selected'),$(this),$(this).find('input[type="checkbox"]'))
    });
    $('tr input[type="checkbox"]').live('click',function(e){
        e.stopPropagation();
        checkCheckbox($(this).attr('checked'),$(this).closest('tr'),$(this))
    });