I've a check all checkbox where it check all the checkboxes once it is checked and vice-versa for uncheck .
How to uncheck the check all checkbox if any of the checkbox is unselected and check the check all check box if all the checkboxes are selected.
HTML
<form action="#">
<p><label><input type="checkbox" id="checkAll"/> Check all</label></p>
<fieldset>
<legend>Loads of checkboxes</legend>
<p><label><input type="checkbox" /> Option 1</label></p>
<p><label><input type="checkbox" /> Option 2</label></p>
<p><label><input type="checkbox" /> Option 3</label></p>
<p><label><input type="checkbox" /> Option 4</label></p>
</fieldset>
</form>
JavaScript
$("#checkAll").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
Aucun commentaire:
Enregistrer un commentaire