JSFiddle - React, Tailwind, and code Playground

HTML

<fieldset>
    <!-- these will be affected by check all -->
    <div>
        <input type="checkbox" ID="checkall1" onclick="CheckAllClick(this);">Check all</div>
    <div>
        <input type="checkbox" />Checkbox</div>
    <div>
        <input type="checkbox" />Checkbox</div>
    <div>
        <input type="checkbox" />Checkbox</div>
</fieldset>
<fieldset>
    <!-- these won't be affected by check all; different field set -->
    <div>
        <input type="checkbox" ID="checkall2" onclick="CheckAllClick(this);">Check all</div>
    <div>
        <input type="checkbox">Checkbox</div>
    <div>
        <input type="checkbox">Checkbox</div>
    <div>
        <input type="checkbox">Checkbox</div>
</fieldset>

JavaScript

function CheckAllClick(elem) {
       $(elem).closest('fieldset').find(':checkbox').prop('checked', elem.checked);

   }