gt,lt计数都是下标从0开始,而且不论大小于,都不包括它自己本身。
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title></title>
</head>
<body>
<table style="float:left; 200px;">
<tr>
<td>0</td>
</tr>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>3</td>
</tr>
<tr>
<td>4</td>
</tr>
<tr>
<td>5</td>
</tr>
<tr>
<td>6</td>
</tr>
</table>
<table style="float:left; 200px;">
<tr>
<td>0</td>
</tr>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>3</td>
</tr>
<tr>
<td>4</td>
</tr>
<tr>
<td>5</td>
</tr>
<tr>
<td>6</td>
</tr>
</table>
<table style="float:left; 200px;">
<tr>
<td>0</td>
</tr>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>3</td>
</tr>
<tr>
<td>4</td>
</tr>
<tr>
<td>5</td>
</tr>
<tr>
<td>6</td>
</tr>
</table>
</body>
<script src="jquery.js"></script>
<script type="text/javascript">
//情况1
$("table:eq(0) tr:lt(3)").css("backgroundColor", "yellow");
//情况2。gt(0)以后,索引为0的已经被排除了,那么剩下的有重新计数,下标又从0开始。
$("table:eq(1) tr:gt(0):lt(3)").css("backgroundColor", "red");
//情况3。gt(3)以后,索引为0,1,2,3的已经被排除了,那么剩下的有重新计数,下标又从0开始。
$("table:eq(2) tr:gt(3):lt(2)").css("backgroundColor", "green");
</script>
</html>
结果如下: