计算使用jquery选中的html复选框的数量 [英] calculate the number of html checkbox checked using jquery
本文介绍了计算使用jquery选中的html复选框的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何计算用户使用jquery检查的复选框的数量?
我想要做的是限制检查表单中复选框的数量例如,当用户超过此范围时,显示一条警告消息。
解决方案
有多种方法可以: / p>
方法1:
$('。checkbox_class_here:checked')。size());方法2: alert($('input [name = checkbox_name]')。attr('checked'));方法:3
$ b alert($(:checkbox:checked)。
how can i calculate the number of checkboxes that a user has checked using jquery?
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:
Method 1:
alert($('.checkbox_class_here:checked').size());
Method 2:
alert($('input[name=checkbox_name]').attr('checked'));
Method: 3
alert($(":checkbox:checked").length);
这篇关于计算使用jquery选中的html复选框的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文