Thanq Karl,
and thank Mike Alsup too
On Jul 18, 9:50 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> On Jul 18, 2008, at 9:22 AM, Mike Alsup wrote:
>
> > You could create a new selector shortcut for that case like this:
>
> > jQuery.expr[':'].lastx = function(a,i,m,r){return i>=r.length-m[3];};
>
> You could also just use the slice() method :-)
>
> $('div').slice(-2);
Nice!
On Jul 18, 2008, at 9:22 AM, Mike Alsup wrote:
You could create a new selector shortcut for that case like this:
jQuery.expr[':'].lastx = function(a,i,m,r){return i>=r.length-m[3];};
And then use it like this:
var lastTwoDivs = $('div:lastx(2)');
You could also just use the slice() method
> The selector can match last one elememt by using ":last", but how
> about last n elements?Are there some simple way to do this?
You could create a new selector shortcut for that case like this:
jQuery.expr[':'].lastx = function(a,i,m,r){return i>=r.length-m[3];};
And then use it like this:
v
4 matches
Mail list logo