JSFiddle - React, Tailwind, and code Playground

by Vladimir

HTML

<p id="controls">
  <tr>
    <th><input type="checkbox"   name="id[]" value="1"></th>
  </tr>
  <tr>
    <th><input type="checkbox"   name="id[]" value="2"></th>
  </tr>
  <tr>
    <th><input type="checkbox"   name="id[]" value="3"></th>
  </tr>
</p>
<input type="checkbox" id="checkbox">Main

JavaScript

$(function () {
        $('#checkbox').click(function(){
            if ($(this).is(':checked')){
                $('#controls input:checkbox').prop('checked', true);
            } else {
                $('#controls input:checkbox').prop('checked', false);
            }
        });
    });