Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

.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.

Tagged , ,

2 comments

  1. 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 - #

  2. 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 - #

Comments are closed.
A django site