In asp.net, the server control automatically generates the ID and name attributes. Therefore, it is more difficult to use javascrip to achieve full selection.
By searching for information, I think it is relatively simple to use javascrip + jquery in combination to implement it from a simple perspective.
The following code is used:
[Javascript]
Function quanxuan (){
Var obj = document. getElementById ("btnSelectAll ");
If (obj. value = "select all "){
$ ("Input: checkbox"). attr ("checked", true); // set all to selected
Obj. value = "cancel"
}
Else {
$ ("Input: checkbox"). attr ("checked", false); // set all to unselected
Obj. value = "select all"
}
}
Call code:
[Html] www.2cto.com
<Input type = "button" id = "btnSelectAll" value = "select all" class = "input_btn_search" onclick = "quanxuan ()"/>
Of course, my practice is rough. I have selected all the checkpoints in the document. If you want to select a specific checkbox, such as a check box in a table, you can use the jquery selector to filter. For example:
[Html]
$ ("Table: checkbox ")
Author: lzjpc500