:gt() Selector
gt selector
version added: 1.0jQuery(':gt(index)')
描述: 選擇所有大于給定索引值的元素
索引相關(guān)的選擇
這種索引相關(guān)的選擇器(包括這個“大于”選擇器)過濾他們前面的匹配表達式的集合元素。他們縮小匹配元素的順序范圍。例如,如果第一個選擇器使用類選擇器( .myclass )進行匹配,四個元素返回,這些元素是給定索引是0到3。
請注意,由于JavaScript數(shù)組使用基于0的索引 ,這些選擇器也是如此。這就是為什么$('.myclass:gt(1)')選擇器選擇文檔中第二個MyClass類的元素,而不是第一個。與此相反,:nth-child(n)是基于1的索引的,以符合CSS規(guī)范。
Example:
Finds TD #5 and higher. Reminder: the indexing starts at 0.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<table border="1">
<tr><td>TD #0</td><td>TD #1</td><td>TD #2</td></tr>
<tr><td>TD #3</td><td>TD #4</td><td>TD #5</td></tr>
<tr><td>TD #6</td><td>TD #7</td><td>TD #8</td></tr>
</table>
<script>$("td:gt(4)").css("text-decoration", "line-through");</script>
</body>
</html>