Skip to Menu

Various plugins for working with checkboxes.

Breaking changes since version 1

These plugins behave differently than the previous version, which is still available for download. The first parameter is for only toggling/checking/unchecking checkboxes that match the expression (you can use :not(#checkbox1) for filtering out items). radioCheckboxGroup has also been updated to allow selection by jQuery expression (i.e. class name) as well as name. The last 5 checkboxes in the table below behave like radio buttons. They can still be checked via JavaScript though.

This plugin is available for download via jQuery SVN

Sample form #myform

  Last Name First Name Title
Davolio Nancy Sales Representative
Fuller Andrew Vice President, Sales
Leverling Janet Sales Representative
Peacock Margaret Sales Representative
Buchanan Steven Sales Manager
Suyama Michael Sales Representative
King Robert Sales Representative
Callahan Laura Inside Sales Coordinator
Dodsworth Anne Sales Representative

toggleCheckboxes

Use: $("#myform").toggleCheckboxes(); to toggle all checkboxes in '#myform'.

Ignore checkboxes matching a jQuery expression : $("#myform").toggleCheckboxes(":not(#checkbox1)");

Return the checked items: $("#myform").toggleCheckboxes(".top5", true);
(use "*" instead of ".top5" if you want to toggle all of them)

checkCheckboxes

Use: $("#myform").checkCheckboxes(); to check all checkboxes in '#myform'.

Ignore checkboxes matching a jQuery expression : $("#myform").checkCheckboxes(":not(#checkbox1)");

Return the checked items: $("#myform").checkCheckboxes(".top5", true);
(use "*" instead of ".top5" if you want to check all of them)

unCheckCheckboxes

Use: $("#myform").unCheckCheckboxes(); to uncheck all checkboxes in '#myform'.

Ignore checkboxes matching a jQuery expression : $("#myform").unCheckCheckboxes(":not(#checkbox1)");

Return the unchecked items: $("#myform").unCheckCheckboxes(".top5", true);
(use "*" instead of ".top5" if you want to uncheck all of them)

radioCheckboxGroup

Makes all checkboxes with the given name behave like a radio button list. Code was originally written by 'Rob D' in an email sent to me.

Use: $.radioCheckboxGroup("name").

You can also filter using an expression: $.radioCheckboxGroup("name", ".myclass");

If you use a blank string "", or null instead of "name", it will apply to all checkboxes on the page.

The checkboxes that this is applied to can still be checked via JavaScript (i.e. using toggleCheckboxes or checkCheckboxes).