jQuery eq()Method
Examples
Select the second <p> element (index 1):
$("p").eq(1).css("background-color","yellow");
Try it Yourself »
Definition and Usage
The eq() method returns the element with the specified index number of the selected elements.
Index numbers start at 0, so the first element has index 0 (not 1).
Syntax
$(selector).eq(index)
| Parameter | Description |
|---|---|
| index | Required. Specifies the index of the element. Can be an integer or a negative number. Note:Using a negative number starts the index from the end of the selected elements. |
More Examples
Using a negative number
Use a negative number to return the second <p> element from the end of the selected elements.
Other Extensions
jQuery Traversal Methods