On 10/7/06, Michael Geary <[EMAIL PROTECTED]> wrote:
> > > jQuery.fn.reverse = function() {
> > >    this.pushStack(this.get().reverse());
> > >    return this;
> > > }
>
> > Nice. That is a better approach then just doing
> > jQuery.fn.reverse = [].reverse.
>
> I'm curious, what is the advantage of one approach over the other?

Since the first once uses jQuery's nice pushStack method, you can now
do (in a silly example):

$("div")
    .reverse()
        .addClass("test")
    .end()
    .find("p") ....

or even:

$("div").reverse(function(){
    alert("All the divs, in reverse: " + this);
});

--John

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to