Bug Tracker

Opened 7 years ago

Closed 7 years ago

#4744 closed bug (invalid)

: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:
Blocked by: Blocking:

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 (1)

comment:1 Changed 7 years ago by dmethvin

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

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.