Select all events for jquery, and select all events for jquery.
& Lt; td width = "82%" colspan = "3" & gt;
<Input type = "checkbox" id = "all"> select all & nbsp;
<Input type = "checkbox" id = "reverse"> invert Selection
</Td>
& Lt; td width = "82%" colspan = "3" & gt;
<S: checkboxlist name = "resUuids" list = "resList" listKey = "uuid" listValue = "name"> </s: checkboxlist>
</Td>
$ (Function (){
// Select all
$ ("# All"). click (function (){
// Select all the following components
// $ ("[Name = resUuids]") is a multi-component with an array of objects.
// $ ("[Name = resUuids]"). attr ("checked", "checked ");
// Obtain the status of the current component first
// $ (This). attr ("checked ")
// Set all components to the corresponding status
// $ ("[Name = resUuids]"). attr ("checked", $ (this). attr ("checked "));
// $ (This). attr ("checked") What is the obtained value?
// Alert ($ (this). attr ("checked"); // undefined
// $ ("[Name = resUuids]"). attr ("checked", "undefined ");
// Js syntax rule. All values except false, FALSE, "false", "FALSE", and 0 are considered as true.
// $ ("[Name = resUuids]"). attr ("checked", false );
Var flag = $ (this). attr ("checked ");
$ ("[Name = resUuids]"). attr ("checked", flag = "checked ");
});
// Invert Selection
$ ("# Reverse"). click (function (){
// Switch the status of all components to the reverse status of the original status
// $ ("[Name = resUuids]"). attr ("checked ",! ($ ("[Name = resUuids]"). attr ("checked") = "checked "));
// When the selector selects multiple components, operations are performed on the first component to obtain any data of the component.
// Alert (! ($ ("[Name = resUuids]"). attr ("checked") = "checked "));
// Iterate each component so that its operation status is reversed for the original status of the corresponding component
$ ("[Name = resUuids]"). each (function (){
// Use the each operation to perform operations on each component
Var flag = $ (this). attr ("checked ");
$ (This). attr ("checked ",! (Flag = "checked "));
});
CheckSelect ();
});
// Bind the component
$ ("[Name = resUuids]"). click (function (){
// Set the all-selected status to the overall status value of all components.
CheckSelect ();
});
Function checkSelect (){
Var allFlag = true;
$ ("[Name = resUuids]"). each (function (){
Var flag = $ (this). attr ("checked") = "checked ";
// &: Bit operation and &: logical and
AllFlag = allFlag & flag;
});
$ ("# All"). attr ("checked", allFlag );
}
});