Bug Tracker

Opened 12 years ago

Closed 12 years ago

#7711 closed bug (invalid)

last, first bad cached

Reported by: anonymous Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


var questor = $("td"); var obj = questor.last(".class1"); var objRet2 = questor.last(".class2"); /*bug return cached result obj*/

same with selector first;

Change History (1)

comment:1 Changed 12 years ago by jitter

Resolution: invalid
Status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report. After checking your report I come to the conclusion that this is no bug in jQuery but rather a misunderstanding on what .last() does.
The documentation for last() says:

Reduce the set of matched elements to the final one in the set.

Also the api is specified as .last() (note how there is no parameter to this method, the same holds for .first()).

So as you can see from the documentation the last() method doesn't accept any parameters it just returns a new jQuery object containing exactly one element (the last one from the set of the jQuery object you call it on). This is way you get the same result twice, the two calls are identical as the parameter gets ignored.

live test case

Last edited 12 years ago by jitter (previous) (diff)
Note: See TracTickets for help on using tickets.