How to count every checked checkboxes
you can do it this way
$(document).ready(function(){
$('input[type="checkbox"]').click(function(){
alert($('.test:checked').length);
});
});
HTML i used
<input type="checkbox" name="test" class="test" value=""/>
<input type="checkbox" name="test" class="test" value=""/>
<input type="checkbox" name="test" class="test" value=""/>
<input type="checkbox" name="checkAll" class="checkAll" value=""/>
Hope this helps
You can use a function to update the counter :
function updateCounter() {
var len = $("#general-content input[name='wpmm[]']:checked").length;
if(len > 0){
$("#general i .counter").text('('+len+')');
} else {
$("#general i .counter").text(' ');
}
}
and call this function when a checkbox's state is changed (including the selectAll checkboxes)
Here is an updated jsFiddle : http://jsfiddle.net/8PVDy/4/
$('input[type="checkbox"]:checked').length