i'm trying to get the list of checkboxes and the count that are checked. I have this:
var obj = $(this).closest('li').find(':checkbox');
var childCount=$(obj).size();
var checkedCount=$(obj).(':checked').length;
I get error on checkedCount
??
We can check the status of a checkbox by using the :checked jQuery selector together with the jQuery function is . For example: $('#el').is(':checked') .
Checking if a checkbox is checked First, select the checkbox using a DOM method such as getElementById() or querySelector() . Then, access the checked property of the checkbox element. If its checked property is true , then the checkbox is checked; otherwise, it is not.
$("#checkbox1"). prop('checked', true);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With