JSFiddle - React, Tailwind, and code Playground
by nayish
HTML
<table>
<tr><td><input type="checkbox" name="checkbox1" class="rowSelectCheckbox"></td></input></tr>
<tr><td><input type="checkbox" name="checkbox2" class="rowSelectCheckbox"></td></input></tr>
<tr><td><input type="checkbox" name="checkbox3" class="rowSelectCheckbox"></td></input></tr>
<tr><td><input type="checkbox" name="checkbox4" class="rowSelectCheckbox"></td></input></tr>
</table>
<input type="checkbox" name="checkbox_select" id="lastCheckbox"></input>
JavaScript
$('.rowSelectCheckbox').change( function() {
flag = false;
$('.rowSelectCheckbox').each( function() {
if ($(this).is(':checked')) {
flag = true;
}
});
$('#lastCheckbox').prop('checked', flag);
});