'keep checkbox disabled and unchecked if any other two checkboxes are checked
I am trying to keep #b0 disabled and unchecked if #b1 and/or #b2 is/are checked. The snippet below re-enables #b0 if uncheck #b1 or #b2
let boxes = $('#b1, #b2');
boxes.click(function() {
if (boxes.filter(':checked').length > 0) {
$("#b0").prop("disabled", this.checked).prop({"checked": false}, this.checked);
}
})
<label for="b0">1</label>
<input id="b0" name="name0" type="checkbox">
<label for="b1">2</label>
<input id="b1" name="name1" type="checkbox">
<label for="b2">3</label>
<input id="b2" name="name2" type="checkbox">
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
