Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get count with a selection like $(".... :checked")?

Tags:

jquery

I need to get a count of checkboxes that are currently checked.

How do I do that?

$(".... :checked").count() doesn't work.

like image 797
Blankman Avatar asked Jan 21 '11 16:01

Blankman


People also ask

How do I count the number of checkboxes selected?

To get a list of all checked checkboxes, you can use the :checked selector like $('input:checkbox:checked') .

How do you evaluate a checkbox selection?

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.

When a checkbox is selected what will be its value?

If a checkbox is marked or checked, it indicates to true; this means that the user has selected the value. If a checkbox is unmarked or not checked, it indicated to false; this means that the user has not selected the value.


2 Answers

$("input:checked").length;
like image 69
David Tang Avatar answered Oct 04 '22 20:10

David Tang


Try this

$("input:checked").length
like image 20
profanis Avatar answered Oct 04 '22 20:10

profanis