.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).
Remember
$("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
Build a set, then pick one position from that set.
Select a collection (e.g. $("li") or $("div.box")).
Call .eq(n) with a zero-based index.
Or use a negative index from the end (jQuery 1.4+).
Chain methods on the one-element set — or check .length if it might be empty.
Remember: the index is inside the current set, not the whole document.
Piece
Required?
Role
Matched set
Yes
Collection to reduce
index
Yes
0-based from start (1.1.2+)
indexFromEnd
Alt form
Negative from end (1.4+)
Return value
—
New jQuery set (0 or 1 element)
Pseudocode
Pseudocode
call $(set).eq(index)
if index < 0:
index = set.length + index // from the end
if 0 ≤ index < set.length:
return new jQuery object with set[index]
else:
return empty jQuery object (length 0)
Reference
Cheat Sheet
Index shortcuts side by side.
Topic
Detail
Syntax
.eq(index)
Since
1.1.2 · negative in 1.4
.eq(0)
≈ .first()
.eq(-1)
≈ .last()
Out of range
Empty set — no throw
vs .get(n)
jQuery object vs DOM node
vs .slice()
One item vs a range
Try it
Live Preview
Pick a list item by index — including negative positions from the end.
list item 1
list item 2
list item 3
list item 4
list item 5
Official idea: .eq(2) is the third item (zero-based). .eq(-2) is two from the end.
Result
Ready — choose a call and click Run.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
One line:.eq(n) keeps one element from the current set — count from zero, or from the end with a negative index.
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.