directly on the code.
<textarea id="runcode89892"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead runat=" Server "> <title>index</title > <script src= "http://img.jb51.net/jslib/jquery/jquery14.js" ></script> <script type= "text/" JavaScript "> $ (Function () {$ (" #CheckAll "). Click (function () {var flag = $ (this). attr (" checked "); $ ("[Name=subbox]:checkbox"). each (function () {$ (this). attr ("checked", flag); })}) </script> </pead> <body> <div> <input id= "Checkall" type= "checkbox"/> Select all &L T;input name= "Subbox" type= "checkbox"/>1 <input "name= subbox" type= "checkbox"/>2 <input "name=" type = "checkbox"/>3 <input name= "Subbox" type= "checkbox"/>4 </div> </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
The following code is more complete, is based on the control principle of JS implementation
Copy Code code as follows:
<script src= "Http://img.jb51.net/jslib/jquery/jquery14.js" ></script>
<script type= "Text/javascript" >
Select All
function Checkedall () {
$ (': CheckBox '). attr (' checked ', ' checked ');
}
No choice.
function Checkedno () {
$ (': CheckBox '). attr (' checked ', ');
}
Anti-election
function Checkedrev () {
var arr = $ (': CheckBox ');
for (Var i=0;i<arr.length;i++) {
arr[i].checked =! arr[i].checked;
}
}
</script>
<body>
<div>
<input id= "Checkall" type= "checkbox"/>
<input name= "Subbox" type= "checkbox"/>
<input name= "Subbox" type= "checkbox"/>
<input name= "Subbox" type= "checkbox"/>
<input name= "Subbox" type= "checkbox"/>
</div>
<input type= "button" Name= "Btncheckedall" value= "All selected" onclick= "Javascript:checkedall ();"/>
<input type= "button" Name= "Btncheckedno" value= "all do not choose" onclick= "Javascript:checkedno ();"/>
<input type= "button" Name= "Btncheckedrev" value= "onclick=" Javascript:checkedrev (); "/>
</body>