<!doctype html>
<meta charset= "Utf-8" >
<title> use jquery for light bar effects </title>
<link href= "4-1.css" rel= "stylesheet" type= "Text/css"/>
<script type= "Text/javascript" src= ". /jquery-1.11.2.js "></script>
<script type= "Text/javascript" >
$ (function () {
$ ("#tbStudent tr:gt (0)"). Hover (
function () {
$ (this). AddClass ("selected");
},function () {
$ (this). Removeclass ("selected")
}
);
Full selection and inverse selection
$ ("#chkAll"). Click (function () {
var checkedval=$ (this). attr ("Checked", "checked");
$ (". Chk"). each (function () {
var subchecked=$ (this). attr ("checked");
if (subchecked!=checkedval)
$ (this). Click ();
});
});
});
</script>.
<body>
<table id= "Tbstudent" >
<tr>
<th><input type= "checkbox" id= "Chkall" name= "Chkall"/> Select all </th>
<th> number </th><th> name </th><th> age </th><th> Sex </th>
</tr>
<tr>
<td><input type= "checkbox" id= "Chk" class= "Chk"/></td>
<td>S001</td><td> Zhang San </td><td>22</td><td> men </td>
</tr>
<tr>
<td><input type= "checkbox" id= "Checkbox1" class= "Chk"/></td>
<td>S002</td><td> John Doe </td><td>22</td><td> Women </td>
</tr>
<tr>
<td><input type= "checkbox" id= "Checkbox2" class= "Chk"/></td>
<td>S003</td><td> Harry </td><td>22</td><td> men </td>
</tr>
<tr>
<td><input type= "checkbox" id= "Checkbox3" class= "Chk"/></td>
<td>S004</td><td> Caifan </td><td>22</td><td> Men </td>
</tr>
<tr>
<td><input type= "checkbox" id= "Checkbox4" class= "Chk"/></td>
<td>S005</td><td> Tianqi </td><td>22</td><td> Female </td>
</tr>
</table>
</body>
@charset "Utf-8";
/* CSS Document */
table{
width:640px;
Border-collapse:collapse;
}
Table th{
Border:solid 1px black;
Background-color:gray;
}
Table td{
Border:solid 1px black;
}
. highlight{
Background-color:highlight;
}
. selected{
Background-color:yellow;
}
Using jquery to achieve light bar effects