查找所有复选框都在jQuery中选中 [英] Finding all checkboxes are checked in jQuery
本文介绍了查找所有复选框都在jQuery中选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有很多复选框
<input id="1" class="paid" type="checkbox" />
<input id="2" class="paid" type="checkbox" />
<input id="3" class="paid" type="checkbox" />
<input id="4" class="paid" type="checkbox" />
我想写一些jQuery来检查所有复选框是否都被选中,然后执行一个动作,但是如何?
I would like to write some jQuery to check if all checkboxes are checked then perform an action but how?
推荐答案
像这样:
if (!$('input.paid[type=checkbox]:not(:checked)').length)
do('stuff');
这将检查是否有未选中的项,如果没有则进行填充(即,它们都已选中).
This will check if there are any that are unchecked, and do stuff if there aren't (i.e. they are all checked).
这篇关于查找所有复选框都在jQuery中选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文