Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Style type = "text/css">
# NewsTable {margin: 100px auto ;}
</Style>
<Script language = "javascript" type = "text/javascript" src = "jquery1.1.2.js"> </script> <! -Connect to the network by uploading the file -->
<Script language = "javascript" type = "text/javascript">
// Achinan exercises
$ (Document). ready (function (){
$ ("# BtnOk"). click (function (){
This. value = this. value = "select all "? "Invert selection": "select all ";
$ ("Input [@ type = 'checkbox']"). checkCbx ();
});
});
// When your code shows each, you should overwrite the above Code to construct a plug-in. One sentence in the jquery tutorial
$. Fn. checkCbx = function (){
Return this. each (function (){
This. checked =! This. checked;
});
}
</Script>
<Title> untitled document </title>
</Head>
<Body>
<Table border = "1" id = "newsTable">
<Tr>
<Th> select </th>
<Th> Id </th>
<Th> author </th>
</Tr>
<Tr>
<Td> <input type = "checkbox" name = "cbx"/> </td>
<Td> 1 </td>
<Td> achinan </td>
</Tr>
<Tr>
<Td> <input type = "checkbox" name = "cbx"/> </td>
<Td> 2 </td>
<Td> achinan </td>
</Tr>
<Tr>
<Td> <input type = "checkbox" name = "cbx"/> </td>
<Td> 3 </td>
<Td> achinan </td>
</Tr>
<Tr>
<Td> <input type = "checkbox" name = "cbx"/> </td>
<Td> 4 </td>
<Td> achinan </td>
</Tr>
<Tr>
<Td> <input type = "checkbox" name = "cbx"/> </td>
<Td> 5 </td>
<Td> achinan </td>
</Tr>
<Tr>
<Td> <input type = "checkbox" name = "cbx"/> </td>
<Td> 6 </td>
<Td> achinan </td>
</Tr>
<Tr>
<Td colspan = "3"> <input type = "button" name = "btnOk" id = "btnOk" value = "select all"/> </td>
</Tr>
</Table>
</Body>
</Html>