jeudi 29 janvier 2015

Having Issue On Deselecting Above Checkboxes (None Of Above)

Can you please take a look at this demo and let me know how I can fix the code for last checkbox in a way to deselect all of above checkboxes when check and do nothing on un check statues?



<input id="selectAll" type="checkbox" name="slectAll">
<label for="selectAll">Yes, Select All</label>
<fieldset id="group_1">
<input type="checkbox" name="numbers[]" value="0" />Item 1<br />
<input type="checkbox" name="numbers[]" value="1" />Item 2<br />
<input type="checkbox" name="numbers[]" value="2" />Item 3<br />
<input type="checkbox" name="numbers[]" value="3" />Item 4<br />
<input type="checkbox" name="numbers[]" value="4" />Item 5<br />
</fieldset>
<input id="planB" type="checkbox" name="planB">
<label for="planB">I am not Sure</label>

<script>
$(function() {
var $all = $('input:checkbox[name=slectAll]').change(function() {
$checks.prop("checked", this.checked);
});

var $checks = $('#group_1 :checkbox').change(function() {
$all.prop("checked", $checks.not(':checked').length == 0);
});

var $none = $('input:checkbox[name=planB]').change(function() {
$checks.prop("checked", this.checked);
});

});
</script>


Thanks





Aucun commentaire:

Enregistrer un commentaire