JSFiddle - React, Tailwind, and code Playground

HTML

<table>
    <tr class="row1">
        
        <input type="checkbox" id="checkall"/> <--click this
        </tr>
     <tr class="row2">
        <input type="checkbox"/>
        <input type="checkbox"/>
        <input type="checkbox" class="subcheck"/>
         </tr>
             <tr class="row3">
        <input type="checkbox"/>
        <input type="checkbox"/>
        <input type="checkbox" class="subcheck"/>
         </tr>
             <tr class="row4">
        <input type="checkbox"/>
        <input type="checkbox"/>
        <input type="checkbox" class="subcheck"/>
         </tr>
             <tr class="row5">
        <input type="checkbox"/>
        <input type="checkbox"/>
        <input type="checkbox" class="subcheck"/>
         </tr>
</table>

JavaScript

$('#checkall:checkbox').change(function () {
    if($(this).attr("checked")) $('input:checkbox').attr('checked','checked');
    else $('input:checkbox').removeAttr('checked');
});