I have the following checkboxes in multiple divs.
<div class="div1"> <input type="checkbox" class="chkbox" value="101"> This is 101 <input type="checkbox" class="chkbox" value="102"> This is 102 <input type="checkbox" class="chkbox" value="103"> This is 103 </div> <div class="div2"> <input type="checkbox" class="chkbox" value="110"> This is 110 <input type="checkbox" class="chkbox" value="102"> This is 102 <input type="checkbox" class="chkbox" value="101"> This is 101 </div>
As shown above, some flags have the same value (e.g. 101) for multiple divs. Now that the checkbox is checked, I need to check other checkboxes with the same value. Similarly, to uncheck.
$(".chkbox").change(function() { // If checked if (this.checked) // find other checkboxes with same value and check them else // find other checkboxes with same value and uncheck them }
source share