count number of checkboxes in html jquery 1

count number of checkboxes in html jquery

var numberOfChecked = $('input:checkbox:checked').length;
var totalCheckboxes = $('input:checkbox').length;
var numberNotChecked = totalCheckboxes - numberOfChecked;

Here is what the above code is Doing:
1. We’re selecting all the checkboxes on the page and checking to see if they’re checked.
2. We’re counting the number of checkboxes that are checked.
3. We’re counting the total number of checkboxes on the page.
4. We’re subtracting the number of checkboxes that are checked from the total number of checkboxes.

Similar Posts