vbg6fw
Last Updated: February 25, 2016
·
805
· barnettjw
43ea08b4fc547e8a5da87c207bea2123

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

Say Thanks
Respond