It is necessary that when one checkbox is in the checked state, the other three are in the same condition as the first.

 var uhChbox = document.getElementById('uh-burger'); var otherChbox = $('.oth-check'); function btnsFun() { if (uhChbox.checked) { otherChbox.checked; } else { otherChbox.checked = false; } } 

How to do it right?

    1 answer 1

    When the state of the first checkbox changes, it is necessary to duplicate its state on the remaining checkboxes.
    To do this, in the event handler for #uh-burger all .oth-check checkboxes .oth-check be set as the value of the checked property from #uh-burger :

     $("#uh-burger").on("change", function() { $(".oth-check").prop("checked", this.checked); }); 
     <input type="checkbox" id="uh-burger" /> <input type="checkbox" class="oth-check" /> <input type="checkbox" class="oth-check" /> <input type="checkbox" class="oth-check" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

    • one
      And it is possible in a cunning and invalid manner, but in a working way: ask all the related checkboxes the same ID. True, the binding will be bilateral, but the author did not mention that this is unacceptable;) - Inquisitor