Last Updated: February 25, 2016
·
5.647K
· barnettjw

Count Checked Boxes with JQuery

Count the number of HTML check boxes, which are checked using this JQuery script.

$(document).ready(function() {
// ########## Count Boxes ########## //

function countBoxes() {
  var a = $("input[type='checkbox']").length;
    $('#boxes').text(' of ' + a + ' Checked');
}

countBoxes();
$(":checkbox").click(countBoxes);

// ########## Count Checked ########## //

function countChecked() {
  var a = $("input:checked").length;
    $("#checked").text(a);
}

countChecked();
$(":checkbox").click(countChecked);
});

Working demo on codepen.io