JSFiddle - React, Tailwind, and code Playground

HTML

<table>
    <tr>
        <td><input type="checkbox" class="checkall" /></td>
        <td><input type="checkbox" class="checkall" /></td>
        <td><input type="checkbox" class="checkall" /></td>
    </tr>
    <tr>
        <td><input type="checkbox" /></td>
        <td><input type="checkbox" /></td>
        <td><input type="checkbox" /></td>
    </tr>
    <tr>
        <td><input type="checkbox" /></td>
        <td><input type="checkbox" /></td>
        <td><input type="checkbox" /></td>
    </tr>
    <tr>
        <td><input type="checkbox" /></td>
        <td><input type="checkbox" /></td><td><input type="checkbox" /></td>
    </tr>
</table>

JavaScript

$(".checkall").click(function(){
    var $table = $(this).closest("table");
    var index = $(this).closest("tr").children().index($(this).closest("td")) + 1;
    console.log(index);
    $table.find("td:nth-child("+index+") input:checkbox").attr("checked",$(this).is(":checked"));
});