How can I identify the following checkboxes on different lines and check / delete them separately.
<input type="checkbox" value="F" name="eph-ds[2457][]"> <input type="checkbox" value="PR" name="eph-ds[2457][]"> <input type="checkbox" value="DPH" name="eph-ds[2457][]"> <input type="checkbox" value="F" name="eph-ds[2450][]"> <input type="checkbox" value="PR" name="eph-ds[2450][]"> <input type="checkbox" value="DPH" name="eph-ds[2450][]">
where [number] is created dynamically.
Example. If "F" is checked, uncheck "PR". If the "PR" checkbox is checked, clear the "F" checkbox. If the "DPH" box is checked, clear the box.
$(":checkbox").change(function() { var current = this.value; if (current == "F") { $(":checkbox[value=PR]").prop("checked", false); } if (current == "PR") { $(":checkbox[value=F]").prop("checked", false); } if (current == "DPH") { $(":checkbox[value=F]").prop("checked", false); $(":checkbox[value=PR]").prop("checked", false); } });
This code works, but if I uncheck the box in the second line, then the box in the first line will also be unchecked:

jquery
Adrian
source share