The .even() traversing method keeps elements at even zero-based indexes — 0, 2, 4 — from the current jQuery collection. This tutorial covers the official list highlight demos, zebra-striping patterns, comparison with .odd() and the :even selector, and clarifies the difference from CSS :nth-child(even).
01
Syntax
.even()
02
Indexes
0, 2, 4…
03
Zero-based
From zero
04
vs .odd()
1, 3, 5…
05
Zebra rows
Striping
06
Since 3.5
jQuery API
Fundamentals
Introduction
Alternating styles — zebra-striped table rows, every other list item highlighted — are common UI patterns. Instead of looping with an index check, jQuery provides .even() to select every element at an even position in the current collection.
Added in jQuery 3.5, .even() takes no arguments and returns a new jQuery object containing elements at indexes 0, 2, 4, and so on. Counting is zero-based — the first element is index 0, which counts as “even.”
Concept
Understanding the .even() Method
Given a jQuery object with one or more matched elements, .even() filters the collection to those whose zero-based index is even (index % 2 === 0). The index is position within the jQuery object — in document order for a simple $("li") query, but relative to whatever set you have after prior filtering.
Pair .even() with .odd() to style alternating groups. For legacy jQuery before 3.5, use .filter(":even") instead — it follows the same zero-based index rule.
💡
Beginner Tip
In a five-item list, .even() selects items 1, 3, and 5 (human counting) because their indexes are 0, 2, and 4. Item 2 is index 1 — odd, not even.
Foundation
📝 Syntax
General form of .even:
jQuery
.even()
Parameters
None — .even() does not accept any arguments.
Return value
A new jQuery object containing elements at even zero-based indexes (0, 2, 4…) from the original set.
Among .active items only: indexes 0, 2… → bold
Index resets relative to filtered subset
How It Works
After .filter(".active"), the collection may be smaller. .even() indexes into that new set — not the original full li list.
Applications
🚀 Common Use Cases
Zebra table rows — shade every other row for readability.
Alternating list styles — different backgrounds on even-index items.
Carousel indicators — style even-positioned dots or thumbnails.
Grid layouts — highlight even cells in a flattened node list.
Split A/B styling — pair .even() and .odd() for two visual groups.
Post-filter striping — stripe only visible items after a search filter.
🧠 How .even() Filters by Index
1
Start with collection
jQuery object holds N elements in order.
Input
2
Check each index
Keep element when index % 2 === 0.
0, 2, 4
3
Build new set
Return jQuery object with matching elements only.
Subset
4
🖼
Chain styling
Apply .css(), .addClass(), or events on even items.
Important
📝 Notes
Added in jQuery 3.5 — requires jQuery 3.5+; use .filter(":even") on older versions.
Zero-based indexing — index 0 is the first element and counts as even.
Index is relative to the current jQuery collection, not global DOM order after filtering.
Does not modify the DOM — only narrows which elements the jQuery object refers to.
Complements .odd() — together they cover all indexes without overlap.
Not equivalent to CSS :nth-child(even), which uses sibling-based 1-based counting.
Compatibility
Browser Support
.even() requires jQuery 3.5+. It is pure collection filtering with no browser-specific behavior beyond jQuery itself.
✓ jQuery 3.5+
jQuery .even()
Supported in jQuery 3.5, 3.6, and 3.7 across all modern browsers. Not available in jQuery 1.x/2.x — use .filter(':even') instead.
100%With jQuery 3.5+
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
.even()Modern jQuery
Bottom line: Use jQuery 3.5 or later. Pair with .odd() for full alternating striping patterns.
Wrap Up
Conclusion
The jQuery .even() method selects elements at even zero-based indexes from the current collection — 0, 2, 4, and so on. It is the clean, readable way to stripe lists and tables without manual index loops.
Remember the official list lesson: in five items, .even() highlights the 1st, 3rd, and 5th because their indexes are 0, 2, and 4. Use .odd() for the complement, and verify you are on jQuery 3.5+.
Remember zero-based counting — first item is index 0 (even)
Pair .even() with .odd() for full striping
Use on tbody tr for table zebra rows
Cache the collection when calling both .even() and .odd()
Use .filter(":even") only when stuck on jQuery < 3.5
❌ Don’t
Assume human 2nd/4th items — those are odd indexes (1, 3)
Confuse .even() with CSS :nth-child(even)
Expect .even() on jQuery 3.4 or earlier without a polyfill
Forget that filtering changes which indexes count as “even”
Call .even() twice expecting a smaller set — second pass re-indexes from zero
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about .even()
Indexes 0, 2, 4 from the current set.
5
Core concepts
🖼01
.even()
0, 2, 4
API
002
Zero-based
From 0
Index
▬03
Zebra
Striping
Pattern
1,304
.odd()
Complement
Pair
3.505
Since 3.5
Modern
Version
❓ 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. Counting starts from zero, as the jQuery API docs emphasize. Index 0 is the first element, index 2 is the third, index 4 is the fifth. This is index 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 — useful for zebra-striped rows or alternating list styles.
Both target even indexes, but :even is used inside a selector string at query time — $('tr:even'). .even() is a method on an existing jQuery collection — $('tr').even(). Prefer .even() when filtering an already-matched set after .filter() or .find().
No. CSS :nth-child(even) counts DOM child position among siblings (1-based). jQuery .even() counts position in the current jQuery collection (0-based). They often overlap on simple lists but can differ after filtering or complex selectors.
.even() was added in jQuery 3.5. Use jQuery 3.5 or later. In older jQuery versions, use .filter(':even') or .filter(function(i){ return i % 2 === 0; }) instead.
Did you know?
jQuery added .even() and .odd() in version 3.5 as clearer alternatives to the :even and :odd selector pseudos. The naming mirrors native JavaScript array methods, but the index rule matches the long-standing jQuery pseudo-selectors — zero-based, which surprises developers expecting “even” to mean 2nd and 4th items in everyday counting.