.first() and .last() methods for jQuery. I got fed up of expecting these to exist, so I wrote them as a couple of one-liner plugins.
.first() and .last() methods for jQuery. I got fed up of expecting these to exist, so I wrote them as a couple of one-liner plugins.
Better. Amend the
eq()function to:eq: function(i) { if (i < 0) i += this.size(); return this.slice(i, i + 1); }then you can do
.eq(0)instead of.first()and.eq(-1)instead of.last().Dean Edwards - 17th January 2008 01:07 - #
Or something like that. :-)
The important thing is that jQuery's slice notation should be aware of negative indices throughout. Including
get(),eq()etc.Dean Edwardsg - 17th January 2008 01:19 - #