jQuery .even() Method

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

What Is .even()?

.even() (since jQuery 3.5) reduces the matched set to elements at even zero-based indexes — 0, 2, 4, …. It takes no arguments. Returns a new jQuery object; does not change the DOM.

Remember
$("li").even();              // indexes 0, 2, 4 → items 1, 3, 5
$("ul li").even();           // official highlight demo
$("tr").even();              // zebra table rows (1st, 3rd, …)

// Indexes:  0      1      2      3      4
// Items:    1st    2nd    3rd    4th    5th
// .even() → ✓             ✓             ✓
// .odd() →         ✓             ✓
NeedUse
Even indexes (0, 2, 4…)$set.even()
Odd indexes (1, 3, 5…).odd()
Older jQuery$("li:even") or .filter(":even")
One index.eq(0)
Custom keep/drop.filter()

How to Use .even()

Select a set, call .even(), then style or process the result.

  1. Confirm you are on jQuery 3.5+.
  2. Select the collection (e.g. $("ul li")).
  3. Call .even() — no arguments.
  4. Remember: index 0 is even → the first item is included.
  5. Chain .append(), .addClass(), or .css() on the result.
PieceRequired?Role
Matched setYesCollection to reduce
ArgumentsNoneMethod takes no parameters
Index base—Zero-based position in the set
Return value—New jQuery set (0 or more)

Pseudocode

Pseudocode
call $(set).even()

result = empty set
for each element in set with index i (starting at 0):
    if i % 2 === 0:          // even index
        add element to result

return result as a new jQuery object

// 5 items → keeps indexes 0, 2, 4 (1st, 3rd & 5th)

Cheat Sheet

Keep even/odd methods side by side.

TopicDetail
Syntax.even()
SincejQuery 3.5
KeepsIndexes 0, 2, 4, …
vs .odd()Odd indexes 1, 3, 5, …
vs :evenSame idea; method needs 3.5+
vs CSS :nth-child(even)CSS is 1-based; .even() is 0-based
DOM change?No — query only

Live Preview

From five list items, compare .even(), .odd(), and :even.

  • list item 1
  • list item 2
  • list item 3
  • list item 4
  • list item 5

.even() → items 1, 3, and 5 (indexes 0, 2, 4). .odd() → items 2 and 4.

Result
Ready — choose a call and click Run.

jQuery Examples

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

Example 1 — Official: $("li").even()

Mark the 1st, 3rd, and 5th list items (jQuery API demo).

jQuery
$("li").even().append(" [even]");
Try It Yourself

How It Works

  1. Select. Start with every li.
  2. Index. Positions are 0, 1, 2, 3, 4.
  3. Even. Keep only indexes 0, 2, and 4.
  4. Mark. The 1st, 3rd, and 5th items get the suffix.

Example 2 — Official: $("ul li").even()

Highlight even-indexed items inside a list (jQuery API example).

jQuery
$("ul li").even().append(" [highlight]");
Try It Yourself

How It Works

  1. Scope. $("ul li") limits the set to list items in the ul.
  2. Reduce. .even() keeps even indexes only.
  3. First in. The first li is index 0 (even) — included.
  4. Mark. Remaining even-indexed items get the label.

Example 3 — .even() vs .odd()

Split one list into two non-overlapping groups.

jQuery
$("#demo li").even().append(" [even]");
$("#demo li").odd().append(" [odd]");
Try It Yourself

How It Works

  1. even. Keeps indexes 0, 2, and 4.
  2. odd. Keeps indexes 1 and 3.
  3. No overlap. Every item gets exactly one label.
  4. Use. Ideal for alternating styles / zebra rows.

Example 4 — .even() vs :even

Same zero-based idea — method (3.5+) vs selector.

jQuery
var a = $("li").even().length;
var b = $("li:even").length;

$("#out").text(".even()=" + a + " · :even=" + b);
Try It Yourself

How It Works

  1. Method. .even() filters an existing set (needs 3.5+).
  2. Selector. :even works in older jQuery builds.
  3. Same rule. Both use zero-based even indexes.
  4. Prefer. Use .even() when you already have a collection to chain.

Example 5 — Zebra Table Rows

Mark every other data row using even indexes.

jQuery
$("tbody tr").even().append(" ★");
Try It Yourself

How It Works

  1. Scope. Select only tbody tr so the header is ignored.
  2. Even. Keep rows at indexes 0 and 2.
  3. Stripe. Those rows get a marker for zebra styling.
  4. Tip. Pair with .odd() for the other stripe color.

Edge Cases & Pitfalls

Why “even” can feel backwards at first.

zero

First item is index 0 (even)

.even() includes the first element. Everyday “2nd and 4th” thinking maps to .odd(), not .even().

version

Needs jQuery 3.5+

On older builds use $("li:even") or .filter(":even").

css

Not the same as CSS :nth-child(even)

CSS child counting is 1-based. jQuery .even() is 0-based on the matched set.

set

Indexes are in the jQuery set

Order depends on your selector. Reordering the DOM can change which nodes are “even.”

Browser Support

.even() was added in jQuery 3.5. It works in every browser that runs jQuery 3.5+. For older jQuery, use the :even selector or .filter(":even").

✓ jQuery 3.5+

jQuery .even()

Supported in jQuery 3.5 and later (including 3.7.x). Zero-based even indexes on the current matched set.

100% With jQuery 3.5+
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() 3.5+

Bottom line: Safe on modern jQuery. Remember: counting starts at zero — the first item is even.

Performance Notes

ApproachCostBest for
.even()CheapjQuery 3.5+ even indexes
.filter(":even")OKLegacy jQuery before 3.5
$("li:even")OKSelector at query time
Narrower start setFasterPrefer $("ul li") over $("*")

Prefer a scoped selection, then .even(). Cost is dominated by how large the starting set is, not by the even filter itself.

Key Takeaways

  • Role: keep even zero-based indexes (0, 2, 4…).
  • Surprise: first item is even — included by .even().
  • Pair: use .odd() for the other half.
  • Version: jQuery 3.5+; else use :even.

One line: .even() keeps indexes 0, 2, 4… — the 1st, 3rd, and 5th items in everyday counting.

Frequently Asked Questions

.even() reduces the current jQuery collection to elements at even zero-based indexes — 0, 2, 4, and so on. In a five-item list, that means the 1st, 3rd, and 5th elements (indices 0, 2, 4).
Yes. Official docs emphasize counting from zero. Index 0 is the first element, index 2 is the third. This is position in the jQuery object, not CSS :nth-child numbering.
.even() keeps indexes 0, 2, 4… .odd() keeps indexes 1, 3, 5… Together they split a collection into two alternating groups with no overlap.
Both use zero-based even indexes on the matched set. .even() is a method added in jQuery 3.5. $("li:even") is the older selector form. Prefer .even() on jQuery 3.5+ for clearer chaining.
.even() was added in jQuery 3.5. Older versions do not have this method — use $("li:even") or .filter(":even") instead.
No. It only returns a new jQuery object with the even-indexed elements. Chain .css() or .addClass() if you want visual changes.

Next: .filter() Method

Keep matching elements from the current set with a selector or function.

.filter() 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.

9 people found this page helpful