我在多个div中有以下复选框.
<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>
如上所示,一些复选框具有跨多个div的相同值(例如,101).现在,每当选中复选框时,我都需要检查具有相同值的其他复选框.同样,取消选中.
$(".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 }