jQuery .even() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Traversing

Definition

.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.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("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() →         ✓             ✓
CallWhat it does
Matched setCollection to reduce
ArgumentsMethod takes no parameters
Index baseZero-based position in the set
Return valueNew jQuery set (0 or more)

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Confirm you are on jQuery 3.5+.
Step 2Select the collection (e.g. $("ul li")).
Step 3Call .even() — no arguments.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

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.

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.

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.

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: .odd() Method

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

.odd() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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