Query code
$ (funtion () {
Set even lines and odd lines
$ ("tbody>tr:odd"). AddClass ("ou"); Set style for odd rows (add Style Class)
$ ("Tbody>tr:even"). AddClass ("Dan"); Set style classes for even rows
$ ("Tbody>tr:has (: Checked)"). AddClass ("Ed"); Determines whether the row is selected (returns a Boolean type) to add a style class//has (: checked)) to return a bool value True/false
Search is selected has (: checked)
$ (' tbody>tr '). Click (function () {
var hased = $ (this). Hasclass (' Ed ');
if (hased)
{
$ (this). Removeclass ("Ed"). Find (": Input"). attr ("checked", false);
}
Else
{
$ (this). AddClass ("Ed"). Find (": Input"). attr ("Checked", true);
}
});
Traversing a specified trigger function
})
CSS code:
<style type= "Text/css" >
Table {border:0;border-collapse:collapse;}
TD {Font:normal 12px/17px arial;padding:2px;width:100px;}
th {font:bold 12px/17px
arial;text-align:left;padding:4px;border-bottom:1px solid #333;}
. Dan {background: #FC0}
. ou {background: #FFF}
. ed {background: #669; color: #fff;}
</style>
HTML Code
<body>
<table>
<thead>
<tr><th> </th><th> title </th><th> time </th><th> location </th></tr >
</thead>
<tbody>
<tr>
<td><input type= "checkbox" name= "Choice" value= "" ></td>
<td>php100 Video 1</td><td>2011</td><td> Shanghai </td>
</tr>
<tr>
<td><input type= "checkbox" name= "Choice" value= "" ></td>
<td>php100 Video 2</td><td>2012</td><td> Hangzhou </td>
</tr>
<tr>
<td><input type= "checkbox" name= "Choice" value= "" ></td>
<td>php100 Video 3</td><td>2011</td><td> Jinan </td>
</tr>
<tr>
<td><input type= "checkbox" name= "Choice" value= "" ></td>
<td>php100 Video 4</td><td>2012</td><td> Beijing </td>
</tr>
<tr>
<td><input type= "checkbox" name= "Choice" value= "" ></td>
<td>php100 Video 5</td><td>2011</td><td> Wuhan </td>
</tr>
<tr>
<td><input type= "checkbox" name= "Choice" value= "" ></td>
<td>php100 Video 6</td><td>2012</td><td> Fuzhou </td>
</tr>
</tbody>
</table>
</body>
jquery Set table odd even color and row selected color style jquery set table odd even color and row selected color style