Bug Tracker

Ticket #4744 (closed bug: invalid)

Opened 5 years ago

Last modified 5 years ago

:even and :odd pseudoselectors work opposite the way one would expect

Reported by: kfrazier Owned by: john
Priority: minor Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: even, odd Cc:
Blocking: Blocked by:

Description

The :even and :odd pseudoselectors seem to select the opposite of what I would expect. I stepped through the code, and the apparent reason is that the jQuery code evaluates an element as even if its index within the jQuery object is evenly divisible by two. Since these indices begin at zero, the first, third, fifth and so on elements in the list (in natural counting order, beginning with one) are considered even. I would consider this a bug, since I think it is the opposite behavior from what most people would expect.

Change History

comment:1 Changed 5 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

Even if it's the opposite of what you might expect, it's been documented to work that way for several years. No doubt there is a lot of code that has been written that would be broken if it was changed.

 http://docs.jquery.com/Selectors/even

 http://docs.jquery.com/Selectors/odd

Note: See TracTickets for help on using tickets.