开发者

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

开发者 https://www.devze.com 2023-02-05 19:43 出处:网络
I need to get a count of checkboxes that are cu开发者_高级运维rrently checked. How do I do that?

I need to get a count of checkboxes that are cu开发者_高级运维rrently checked.

How do I do that?

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


$("input:checked").length;


Try this

$("input:checked").length


$(':checkbox:checked').length should give you the required count.


Try this instead:

$(":checked").length


Try .length; for example: $('#some_id input:checked').length.


try .length or .size() - they are essentially the same thing. Each results in the count of the number of elements in the matched set. Apparently .length is the preferred choice, as it is faster.


You need to use length.

$("#something:checked").length;


You can always assign a class to the check box elements and select them using the following syntax:

$('input[class="yourCheckBoxClass"]:checked').length;

This will give you the total of check boxes selected.

0

精彩评论

暂无评论...
验证码 换一张
取 消