Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery get checked checkboxes

Tags:

jquery

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

??

like image 449
ShaneKm Avatar asked May 05 '11 10:05

ShaneKm


People also ask

How check if checkbox is checked jQuery?

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') .

How check if checkbox 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.

How check checkbox is true or false in jQuery?

$("#checkbox1"). prop('checked', true);


1 Answers

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.

like image 50
Mayur Ajiwale Avatar answered Sep 27 '22 17:09

Mayur Ajiwale