find all unchecked checkbox in jquery

2019-01-16 03:22发布

I have a list of checkboxes:

<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!

7条回答
一夜七次
2楼-- · 2019-01-16 04:14

You can use like this :

$(":checkbox:not(:checked)")
查看更多
登录 后发表回答