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 test.
Also, you do not need to wrap obj with $() , because it is already a jQuery object.
source share