jQuery :even Selector

Beginner
6 min read
Updated: Oct 2026
5 examples
Live preview

What Is the :even Selector?

:even (since jQuery 1.0) selects elements at zero-based even indices in the matched set — 0, 2, 4, …. That means the first, third, fifth, and so on. Partner of :odd.

Remember
$("tr:even");               // rows at indices 0, 2, 4 …
$("li:even");               // first, third, fifth items
$("td:even");               // even cells in document order

// Preferred today (jQuery 3.5+):
$("tr").even();             // same as :even
NeedUse
Even indices (0, 2, 4…)$("el").even() · legacy $("el:even")
Odd indices (1, 3, 5…):odd · .odd()
Exactly one index:eq(n) · .eq(n)
After / before an index:gt / :lt
CSS even children (1-based):nth-child(even)

How to Use :even

Build a matched set first, then keep even positions — or migrate to .even().

  1. Select a set ($("tr"), $("li"), …).
  2. Remember: index 0 is even — the first item matches.
  3. Legacy: append :even · Modern: call .even() (3.5+).
  4. For older jQuery without .even(), use .filter(":even").
  5. Do not confuse with CSS :nth-child(even) (1-based, parent-relative).
PieceRequired?Role
Preceding selectorYesBuilds the set that :even / .even filters
Indexing—0-based positions in that set (document order)
Matches—Indices where i % 2 === 0
Return value—jQuery set of even-indexed elements

Pseudocode

Pseudocode
set = $(precedingSelector)   // indices 0 … length-1

call set.filter(":even")
  // or set.even()   // jQuery 3.5+

for each element at position i in set:
    if i % 2 === 0:
        include it

return the filtered jQuery set

Cheat Sheet

Keep these facts handy while filtering even indices.

TopicDetail
Syntax$("sel:even")
SincejQuery 1.0
DeprecatedjQuery 3.4 — prefer .even() (3.5+)
Migration:even → .even()
Indexing0-based → first item is even
Partner:odd / .odd()
vs :nth-child(even)Set filter (0-based) vs CSS child (1-based)
Alt filter$("sel").filter(":even")

Live Preview

Stripe table rows with :even, :odd, or modern .even().

Row with Index #0
Row with Index #1
Row with Index #2
Row with Index #3

Blue rows match :even (indices 0 and 2). First row is included because index 0 is even.

Result
Ready — click Run to filter rows.

jQuery Examples

Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.

Example 1 — Official tr:even

From the jQuery docs: match the first, third, and so on table rows.

jQuery
var rows = $("tr:even").map(function () {
  return $(this).text().trim();
}).get();
$("#out").text("Even rows:\n" + rows.join("\n"));
Try It Yourself

How It Works

  1. Set. All tr rows get indices 0–3.
  2. even. Keeps only indices where i % 2 === 0.
  3. map. Collects each matched row’s text.
  4. Report. Shows Row #0 and Row #2.

Example 2 — Modern .even()

Same rows as :even — the recommended jQuery 3.5+ replacement.

jQuery
$("#out").text(
  ":even → " + $("tr:even").length + "\n" +
  ".even() → " + $("tr").even().length
);
Try It Yourself

How It Works

  1. Rule. :even ↔ .even() (since 3.5).
  2. Select. Pure CSS $("tr") can use querySelectorAll.
  3. Filter. .even() keeps even indices afterward.
  4. Future-proof. Avoids the deprecated pseudo-class.

Example 3 — :even vs :odd

Split the set into complementary halves with no overlap.

jQuery
$("#out").text(
  "even → " + $("tr:even").map(function () {
    return $(this).text().trim();
  }).get().join(", ") + "\n" +
  "odd → " + $("tr:odd").map(function () {
    return $(this).text().trim();
  }).get().join(", ")
);
Try It Yourself

How It Works

  1. even. Indices 0 and 2.
  2. odd. Indices 1 and 3.
  3. Cover. Together they match every row once.
  4. Zebra. Classic striping uses one for shade A and one for B.

Example 4 — First Element Is Even

Counter-intuitive but correct: index 0 is even, so item 1 matches.

jQuery
$("#out").text(
  "First li text: " + $("li").eq(0).text() + "\n" +
  "First :even text: " + $("li:even").eq(0).text() + "\n" +
  "Same? " + ($("li").eq(0).text() === $("li:even").eq(0).text())
);
Try It Yourself

How It Works

  1. Index 0. The first list item is even.
  2. Compare. $("li").eq(0) equals the first :even match.
  3. Expect. Not “2nd, 4th…” — that would be :odd in 0-based terms for “everyday even.”
  4. Tip. Think “even indices,” not “even positions starting at 1.”

Example 5 — .filter(":even")

Official performance tip when you cannot use .even() yet.

jQuery
var labels = $("li").filter(":even").map(function () {
  return $(this).text();
}).get();
$("#out").text(labels.join(", "));
Try It Yourself

How It Works

  1. CSS first. $("li") uses a pure CSS selector.
  2. filter. Keeps even indices from that set.
  3. Result. 1st, 3rd, 5th fruits.
  4. Prefer. On jQuery 3.5+, use .even() instead.

Edge Cases & Pitfalls

Check these before relying on :even for striping.

0-based

First element matches

Index 0 is even. If you wanted “2nd, 4th…” rows in everyday counting, that is closer to :odd.

CSS

Not :nth-child(even)

CSS is 1-based and parent-relative. jQuery :even filters the matched set by 0-based position.

3.4+

Deprecated since jQuery 3.4

Still works today. New code should use .even() (3.5+) or .filter(":even").

bare

Always prefix the set

Write $("tr:even") or $("tr").even() — not a bare $(":even") scan of everything.

Browser Support

:even has been part of jQuery since 1.0. It still works, but is deprecated since jQuery 3.4 — prefer .even() (jQuery 3.5+) for new code.

✓ Deprecated · jQuery 1.0+

jQuery :even

Works across jQuery 1.x–3.x where loaded, but avoid in new projects. Migrate to $("sel").even() on jQuery 3.5+ for better performance and future compatibility.

Legacy Status
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
:even Deprecated 3.4+

Bottom line: Fine for reading older tutorials. For production on jQuery 3.5+, use .even() instead of :even.

Performance Notes

ApproachCostBest for
$("css").even()BestjQuery 3.5+ modern browsers
$("css").filter(":even")GoodPre-3.5 — CSS select then filter
$("el:even")SlowerLegacy only — no querySelectorAll

Because :even is a jQuery extension, the engine cannot hand the whole query to the browser. Select with CSS, then .even() or .filter(":even").

Key Takeaways

  • Role: keep items at even indices (0, 2, 4…) — since jQuery 1.0.
  • Migrate: :even → .even() (3.5+; deprecated 3.4).
  • Gotcha: the first element matches because index 0 is even.
  • Partner: use :odd for the complementary half.

One line: :even picks even indices (including the first) — prefer .even() in modern jQuery.

Frequently Asked Questions

:even selects elements at zero-based even indices in the matched set — 0, 2, 4, and so on. $("tr:even") matches the first, third, and fifth rows. Available since jQuery 1.0.
Because indexing starts at 0. Index 0 is even, so the first element in the set is included. Official docs call this counter-intuitive if you expect “second, fourth…” like everyday counting.
Yes — deprecated in jQuery 3.4. Official docs recommend removing :even from selectors and filtering later with .even() (jQuery 3.5.0+): $("tr").even() replaces $("tr:even").
:even keeps indices 0, 2, 4…; :odd keeps 1, 3, 5…. Together they cover the whole matched set with no overlap.
Official docs: :even is a jQuery extension and cannot use native querySelectorAll. Select with a pure CSS selector first, then use .even() (3.5+) or .filter(":even") for better performance.
No — it filters the jQuery matched set by position in that set, in document order. It is not the same as CSS :nth-child(even), which is 1-based and parent-relative.

Next: :odd Selector

Select odd-indexed elements — the partner filter for zebra striping.

:odd tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful