<table id="table">
<tr>
<th>测试一</th>
<th>测试二</th>
<th>测试三</th>
</tr>
<tr>
<td>张三</td>
<td>男</td>
<td>18</td>
</tr>
<tr>
<td>赵四</td>
<td>女</td>
<td>20</td>
</tr>
<tr>
<td>王五</td>
<td>男</td>
<td>19</td>
</tr>
<tr>
<td>麻六</td>
<td>男</td>
<td>22</td>
</tr>
</table>
<style>
td,th{
border: 1px solid #efefef;
text-align: center;
color:#977878;
font-size: 12px;
padding: 5px 5px;
}
#table{
border:1px solid rgb(226, 226, 226);
width:500px;
margin:60px auto;
}
</style>
<script src="jquery.js"></script>
<script>
$(document).ready(function() {
$("#table tr").attr("bgColor", "#fff"); //为单数行表格设置背景颜色
$("#table tr:even").css("background-color", "#eaeaea"); //为双数行表格设置背颜色素
});
</script>
简单的各行变色