查找jQuery中所有未选中的复选框 [英] Find all unchecked checkboxes in jQuery

查看:110
本文介绍了查找jQuery中所有未选中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复选框列表:

<input type="checkbox" name="answer" id="id_1' value="1" />
<input type="checkbox" name="answer" id="id_2' value="2" />
...
<input type="checkbox" name="answer" id="id_n' value="n" />

我可以收集所有已选中复选框的值;我的问题是如何获取所有未选中复选框的值?我试过了:

I can collect all the values of checked checkboxes; my question is how can get all the values of unchecked checkboxes? I tried:

$("input:unchecked").val();

获取未选中的复选框的值,但是我得到了:

to get an unchecked checkbox's value, but I got:

语法错误,无法识别的表达式:未选中.

Syntax error, unrecognized expression: unchecked.

有人可以阐明这个问题吗?谢谢!

Can anybody shed a light on this issue? Thank you!

推荐答案

错误消息指出,jQuery不包含:unchecked 选择器.
相反,您需要反转:checked 选择器:

As the error message states, jQuery does not include a :unchecked selector.
Instead, you need to invert the :checked selector:

$("input:checkbox:not(:checked)")

这篇关于查找jQuery中所有未选中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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