:eq(index) (since jQuery 1.0) selects the single element at a zero-based index in the matched set. Negative indices (from the end) are supported since 1.8.
Remember
$("td:eq(2)"); // third cell (index 2)
$("li:eq(0)"); // first list item
$("li:eq(-2)"); // second-to-last (since 1.8)
// Preferred today (jQuery 3.4+):
$("td").eq(2); // same as :eq(2)
Remember: one match only — not every “nth” across parents.
For per-list “second item”, loop with .each() and .eq(1) inside.
Piece
Required?
Role
Preceding selector
Yes
Builds the set that :eq / .eq filters
index
Yes
Zero-based position in that set
Negative index
No
Since 1.8 — count from the end
Return value
—
jQuery set with 0 or 1 element
Pseudocode
Pseudocode
set = $(precedingSelector) // indices 0 … length-1
call set.filter(":eq(index)")
// or set.eq(index)
if index is negative:
index = set.length + index // e.g. -1 → last
if 0 <= index < set.length:
return set[index] as a jQuery object
else:
return empty jQuery set
Reference
Cheat Sheet
Keep these facts handy while picking by index.
Topic
Detail
Syntax
$("sel:eq(index)")
Since
1.0 · negative index since 1.8
Deprecated
jQuery 3.4 — prefer .eq()
Migration
:eq(n) → .eq(n)
Indexing
0-based (like JS arrays)
Matches
At most one element
vs :nth-child
Set position (0-based) vs parent child (1-based CSS)
Out of range
Empty set — length 0
Try it
Live Preview
Highlight one table cell with :eq() or the modern .eq() equivalent.
TD #0
TD #1
TD #2
TD #3
TD #4
TD #5
TD #6
TD #7
TD #8
Yellow cell is the match. :eq(2) and .eq(2) select the same cell.
Result
Ready — click Run to pick a cell.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Official td:eq(2)
From the jQuery docs: pick the third table cell.
jQuery
var text = $("td:eq(2)").text();
$("#out").text("Matched: " + text + " (index 2)");
Why. Bare $("li:eq(1)") would only hit the second item globally.
Edge Cases & Pitfalls
Check these before relying on :eq() in real pages.
index
:eq(1) is the second element
Zero-based like JS arrays. The first match is :eq(0), not :eq(1).
nth
Not the same as :nth-child
Set position vs parent child; 0-based vs 1-based. They often pick different elements.
3.4+
Deprecated since jQuery 3.4
Still works today, but new code should use $("sel").eq(n).
scope
One match for the whole set
Need “second in each list”? Loop with .each() and .eq(1) inside each parent.
Compatibility
Browser Support
:eq() has been part of jQuery since 1.0 (negative indices since 1.8). It still works, but is deprecated since jQuery 3.4 — prefer .eq() for new code.
✓ Deprecated · jQuery 1.0+
jQuery :eq()
Works across jQuery 1.x–3.x where loaded, but avoid in new projects. Migrate to $("sel").eq(n) for better performance and future compatibility.
LegacyStatus
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
:eq()Deprecated 3.4+
Bottom line: Fine for reading older tutorials. For production on jQuery 3.4+, use .eq() instead of :eq().
Analysis
Performance Notes
Approach
Cost
Best for
$("css").eq(n)
Best
Modern browsers + jQuery 3.4+
$("el:eq(n)")
Slower
Legacy code only — no querySelectorAll
Huge lists filtered often
Can add up
Cache the set; call .eq() once
Because :eq() is a jQuery extension, the engine cannot hand the whole query to the browser. Select with CSS, then .eq(), for the fastest path.
Remember
Key Takeaways
Role: pick exactly one item by 0-based index — since jQuery 1.0.
Migrate::eq(n) → .eq(n) (deprecated 3.4).
vs nth: set index (0-based) ≠ CSS :nth-child (1-based).
Negative::eq(-2) since 1.8 · or .eq(-2) for the same.
One line::eq(n) picks one element at index n — prefer .eq(n) in modern jQuery.
Frequently Asked Questions
:eq(index) selects the single element at a zero-based index within the matched set. $("td:eq(2)") picks the third td (index 2). Available since jQuery 1.0; negative indices since 1.8.
Yes — deprecated in jQuery 3.4. Official docs recommend removing :eq() from selectors and filtering later with .eq(): $("td").eq(2) replaces $("td:eq(2)").
:eq() filters the jQuery matched set by 0-based position after the preceding selector. :nth-child(n) is CSS — it picks elements that are the nth child of their parent (1-based). $(".myclass:eq(1)") is the second .myclass in the set; :nth-child(1) means first child of its parent.
Since jQuery 1.8, :eq(-index) counts backwards from the last element. $("li:eq(-2)") selects the second-to-last list item. Prefer $("li").eq(-2) in new code.
Official docs: :eq() is a jQuery extension and cannot use native querySelectorAll. $("your-pure-css-selector").eq(index) is faster in modern browsers and avoids the deprecated pseudo-class.
No — :eq() always returns at most one element from the current matched set. To style the second item in each list, loop with .each() and call .eq(1) (or find("li").eq(1)) inside each list.