views:

1387

answers:

1

In jQuery, how does one go about finding all the 'unchecked' checked boxes.

$(':checkbox:checked');

appears to be me all checked boxes, but what I need is all non-checked boxes.

+16  A: 

You use the :not selector, like so:

$('input:checkbox:not(:checked)');

Or the .not function, like so:

$('input:checkbox').not(':checked');

Also note that you should always put input before filters like :radio and :checkbox, as without that the selector are evaluated as *:checkbox which is a really slow selector.

Paolo Bergantino
Thank you Paolo. I had actually played around with the 'not', but I didn't manage to get the ":" in the right place or something. In any case, works now. Thanks. Thanks for guide on *: versus input:
Jim Biddison
Paolo, how do you get so many upvotes for your answers. It baffles me!!
redsquare
compared to mine I mean. I'm lucky to get 2/3.
redsquare