jquery get checked checkboxes
You need to use the filter()
function:
var obj = $(this).closest('li').find(':checkbox');
var childCount = obj.size();
var checkedCount = obj.filter(':checked').length;
filter
Reduce the set of matched elements to those that match the selector or pass the function's test.
Also, you don't need to wrap obj
with $()
, because it's already a jQuery object.
to get checked checkboxes length :
$('input[name^="complete"]:checked').length;
to get unchecked checkboxes length :
$('input[name^="complete"]:unchecked').length;
where "complete"
is a name attribute.