计算使用jquery检查的html复选框的数量 [英] calculate the number of html checkbox checked using jquery

查看:23
本文介绍了计算使用jquery检查的html复选框的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算用户使用 jquery 选中的复选框数量?

how can i calculate the number of checkboxes that a user has checked using jquery?

我想要做的是将表单中复选框的检查次数限制为 10,例如,当用户超出此范围时显示警告消息.

what i want to do is limiting the number of checking for checkboxes in a form to 10 for example and when a user exceeds this range display a warning message.

推荐答案

有多种方法可以做到这一点:

There are multiple methods to do that:

方法一:

alert($('.checkbox_class_here:checked').size());

方法二:

alert($('input[name=checkbox_name]').attr('checked'));

方法:3

alert($(":checkbox:checked").length);

这篇关于计算使用jquery检查的html复选框的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆