<!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>
<title>jquery实现表格颜色的交替显示 - www.jb200.com</title>
<script type="text/
javascript" src="/jquery1.3.2.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".truecolor tr:odd").addClass("color1");
jQuery(".truecolor tr:even").addClass("color2");
jQuery(".truecolor tr").hover(function(){
jQuery(this).addClass("color3")
},function(){
jQuery(this).removeClass("color3")
});
});
</script>
<style type="text/css">
.truecolor {border:1px solid #333;text-align:center;}
.truecolor th {background-color:#333; color:#FFF;}
.color1 {background-color:#DDD; color:#333;}
.color2 {background-color:#EEE; color:#333;}
.color3 {background-color:#666; color:#FFF;}
</style>
</head>
<body>
<table width="450" class="truecolor">
<thead>
<tr>
<th>博客</th>
<th>作者</th>
<th>网址</th>
</tr>
</thead>
<tbody>
<tr>
<td>风格之舞</td>
<td>火德</td>
<td>隔行换色</td>
</tr>
<tr>
<td>赵雷的博客</td>
<td>赵雷</td>
<td>
新浪微博</td>
</tr>
<tr>
<td>寂寞广场</td>
<td>魏春亮</td>
<td>同学录</td>
</tr>
<tr>
<td>淘宝UED</td>
<td>淘宝</td>
<td>经常购物</td>
</tr>
</tbody>
</table>
</body>
</html>