tags:

views:

554

answers:

1

I have a collection of checkboxes

 <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" />

I would like to write some jQuery to check if all checkboxes are checked then perform an action but how?

+14  A: 

Like this:

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).

Greg