$("tr:even"):选取偶数位置的 <tr> 元素,注意下标从0开始;
$("tr:odd"):选取奇数位置的<tr>元素,注意下标从0开始。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>菜鸟教程</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("tr:odd").css("background", "yellow");
});
</script>
</head>
<body>
<h2>欢迎访问我的主页</h2>
<table border="1">
<tr>
<th>网址名</th>
<th>网址</th>
</tr>
<tr>
<td>Google</td>
<td>http://www.google.com</td>
</tr>
<tr>
<td>Baidu</td>
<td>http://www.baidu.com</td>
</tr>
<tr>
<td>菜鸟教程</td>
<td>http://www.runoob.com</td>
</tr>
<tr>
<td>淘宝</td>
<td>http://www.taobao.com</td>
</tr>
</table>
</body>
</html>