JSFiddle - React, Tailwind, and code Playground

HTML

<ul>
<li>
Country
    <input type="checkbox" class="selectAll" id="select1" />Select/Deselect All Country
<ul>
<li>
<input class="modalEntity" id="entity1" type="checkbox" value="group1" name="India">India
<input class="modalEntity" id="entity2" type="checkbox" value="group1" name="UAE">UAE
</li>
</ul>
</li>
<li>
Company
    <input type="checkbox" class="selectAll" id='select2' />Select/Deselect All Company
<ul>
<li>
<input class="modalEntity" id="entity3" type="checkbox" value="group2" name="Apple">Apple
<input class="modalEntity" id="entity4" type="checkbox" value="group2" name="Google">Google
</li>
</ul>
</li>
</ul>

JavaScript

$(document).ready(function() {
    $(".selectAll").click(function(e) {
        $(this).siblings('ul').find('input').attr('checked', $(this).is(":checked"));
    });
});