I have tons of checkboxes that are either checked (checked="checked"
) or unchecked.
I would like to get the number of all checkboxes, unchecked and checked checkboxes.
With check-box I mean <input type="checkbox" />
.
How to do it with jQuery? Thanks in advance!
You could do:
var numberOfChecked = $('input:checkbox:checked').length;
var totalCheckboxes = $('input:checkbox').length;
var numberNotChecked = totalCheckboxes - numberOfChecked;
EDIT
Or even simple
var numberNotChecked = $('input:checkbox:not(":checked")').length;