<a href="http://www.jb51.net/article/21027.htm">http://www.jb51.net/article/21027.htm</a><br>不多说了,直接给代码 <br>代码 <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="38225" class="copybut" id="copybut38225" onclick="doCopy('code38225')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code38225"> <br> <br> <br><title>双色表格</title> <br><style type="text/css"> <BR><!-- <BR>table { <BR>border:solid 1px black; <BR>text-align:center; <BR>border-spacing:0px; <BR>} <BR>th,td { <BR>border:solid 1px black; <BR>width:100px; <BR>} <BR>--> <BR></style> <br><script src="lib/jquery.js" type="text/javascript"></script> <br><script type="text/javascript"> <BR>$().ready(function() { <BR>$('tr:has(th)').css('background','violet'); //表格标题 <BR>$('tr:even:gt(0)').css('background','yellow'); //偶数行,且行数大于0(即标题) <BR>$('tr:odd').css('background','olive'); //奇数行 <BR>}); <BR></script> <br> <br> <br><center> <br><table> <br><tr id="th"> <br><th>姓名</th> <br><th>科目</th> <br><th>成绩</th> <br> </tr> <br><tr> <br><td>张三</td> <br><td>语文</td> <br><td>90</td> <br> </tr> <br><tr> <br><td>张三</td> <br><td>数学</td> <br><td>87</td> <br> </tr> <br><tr> <br><td>李四</td> <br><td>数学</td> <br><td>68</td> <br> </tr> <br><tr> <br><td>王五</td> <br><td>英语</td> <br><td>76</td> <br> </tr> <br> </table> <br> </center> <br> <br> <br> </div>