jQuery eq () method
Examples
Select the second <p> element (index number 1):
$("p").eq(1).css("background-color","yellow");
try it"
Definition and Usage
eq () method returns the element with the specified index number of the selected element.
From the beginning of the index number 0, so the index number of the first element is 0 (not 1).
grammar
$(selector).eq( index )
参数 | 描述 |
---|---|
index | 必需。规定元素的索引。可以是整数或负数。 注意:使用负数将从被选元素的结尾开始计算索引。 |
More examples
Use negative
Use negative returns the second <p> element from the end of the selected element.