.eq(index) (since jQuery 1.1.2) reduces the matched set to one element at a zero-based position. Negative indexes (since 1.4) count from the end. Out of range → empty set (length 0).
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("li").eq(2) // 3rd item (official)
$("li").eq(-2) // 2nd from last (jQuery 1.4+)
$("li").eq(0) // same idea as .first()
$("li").eq(-1) // same idea as .last()
$("li").eq(99) // empty set — safe, no throw
// Returns a jQuery object (keep chaining)
// .get(n) returns a raw DOM node instead
Call
What it does
Matched set
Collection to reduce
index
0-based from start (1.1.2+)
indexFromEnd
Negative from end (1.4+)
Return value
New jQuery set (0 or 1 element)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select a collection (e.g. $("li") or $("div.box")).
Step 2
Call .eq(n) with a zero-based index.
Step 3
Or use a negative index from the end (jQuery 1.4+).
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
Order. Positions follow document order in that set.
eq(2). Keeps the third matched div.
Frequently Asked Questions
.eq(index) reduces the matched set to the single element at that zero-based position. It returns a new jQuery object with one element — or an empty set if the index is out of range. Available since jQuery 1.1.2; negative indexes since 1.4.
Yes. .eq(0) is the first element in the current jQuery set, .eq(1) the second. The index is within the collection, not the whole DOM tree.
Since jQuery 1.4, .eq(-1) is the last element, .eq(-2) is second from last — counting backwards from the end of the set.
You get an empty jQuery object (length 0). Chained methods do nothing; no error is thrown.
.eq() returns a jQuery object so you can keep chaining. .get(index) returns a raw DOM element (or undefined).
.first() is like .eq(0). .last() is like .eq(-1). Use .eq(n) when you need any middle index.