I have two checkboxes, A and B. They should behave according to the following rules:
- A should always be enabled.
- B should only be enabled when A is checked
- If A and B is checked, and A is later un-checked, B should be un-checked and disabled automatically.
I have this code so far:
HTML
<input type="checkbox" id="A" />A
<input type="checkbox" id="B" />B
jQuery
$('#A').change(function () {
if ($(this).attr("checked")) {
$('#B').attr('disabled', false)
} else {
$('#B')
.attr('disabled', true)
.attr('checked', false);
}
}).change();
Aucun commentaire:
Enregistrer un commentaire