Using jquery to achieve light bar effects

Source: Internet
Author: User

<!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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.