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

Sign in with OpenID

Auto-HTML: Line breaks are preserved; URLs will be converted in to links.

Manual XHTML: Enter your own, valid XHTML. Allowed tags are a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

A django site