Mam następujące pola wyboru w wielu elementach div.Zaznacz lub odznacz wszystkie pola wyboru z tą samą nazwą klasy na podstawie wartości
<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>
Jak pokazano powyżej, niektóre pola wyboru mają tę samą wartość (na przykład 101) w wielu elementach div. Teraz, gdy zaznaczone jest pole wyboru, muszę zaznaczyć inne pola wyboru o tej samej wartości. Podobnie, aby odznaczyć.
$(".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
}
Powód głosowania w dół? – Adil