引用(jquery select 2)

Various plugins for working with checkboxes.

Source code available from GitHub or a Zipped download.

Sample form #myform

 Last NameFirst NameTitle
DavolioNancySales Representative
FullerAndrewVice President, Sales
LeverlingJanetSales Representative
PeacockMargaretSales Representative
BuchananStevenSales Manager
SuyamaMichaelSales Representative
KingRobertSales Representative
CallahanLauraInside Sales Coordinator
DodsworthAnneSales 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).

posted @ 2010-10-24 01:59  commas  阅读(305)  评论(0编辑  收藏  举报