From: Dossy Shiobara
I'm surprised there's no .reverse(). i.e.:
$(collection).reverse().each(...)
Great idea!
How about the world's smallest plugin:
jQuery.fn.reverse = [].reverse;
Try it out at http://jquery.com/ by entering these lines into the FireBug
console:
Thanks for the Idea. This works
jQuery.fn.reverse = function() {
this.pushStack(this.get().reverse());
return this;
}
a long that thread a lot more resorting function may be useful.
--
View this message in context:
http://www.nabble.com/.each-backwards---tf2399145.html#a6693603
Sent from
kenton.simpson schrieb:
Thanks for the Idea. This works
jQuery.fn.reverse = function() {
this.pushStack(this.get().reverse());
return this;
}
Nice. That is a better approach then just doing jQuery.fn.reverse =
[].reverse.
-- Jörn
___
jQuery.fn.reverse = function() {
this.pushStack(this.get().reverse());
return this;
}
Huh, at first I though that that code would infinitely recurse, I
totally forgot that .get() returns a clean array of elements - good
call! Just a quick simplification:
jQuery.fn.reverse = function() {
I agree, do you think .sort() and .reverse() could be added to core jQuery
object in the future, or should I just add a plugin.
--
View this message in context:
http://www.nabble.com/.each-backwards---tf2399145.html#a6694292
Sent from the JQuery mailing list archive at Nabble.com.
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?
-Mike
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
Oops, I meant to make that:
jQuery.fn.unshift = jQuery.fn.add;
The issue is, however, that fundamentally .push() or .unshift() won't
work as expected, since adding an item to a jQuery object isn't like
adding a item to a normal array. The jQuery object is more like a
'Set' than it is a true
I agree, do you think .sort() and .reverse() could be added to core jQuery
object in the future, or should I just add a plugin.
Sort, reverse, and splice are definitely possible - maybe for the 1.1 release.
--John
___
jQuery mailing list
I propose hcae:
jQuery.fn.hcae = function( fn, args ) {
return jQuery.hcae( this, fn, args );
};
jQuery.hcae = function( obj, fn, args ) {
if ( obj.length == undefined )
for ( var i in obj )
fn.apply( obj[i], args || [i, obj[i]] );
interesting!
When would length be undefined on an JQ object?
When I first saw the question, I thought of tail recursion, does JS
deal well (optimize) tail recursion?
On 10/6/06, Blair Mitchelmore [EMAIL PROTECTED] wrote:
I propose hcae:
jQuery.fn.hcae = function( fn, args ) {
return
i know js 1.2 does, but i think its only supported in ff 2.0
currently... but dont quote me on that.
On 10/6/06, Ⓙⓐⓚⓔ [EMAIL PROTECTED] wrote:
interesting!
When would length be undefined on an JQ object?
When I first saw the question, I thought of tail recursion, does JS
deal well
On 2006.10.06, Blair Mitchelmore [EMAIL PROTECTED] wrote:
I propose hcae:
Oh, god no. I see the smiley so I'm guessing you're only kidding, but
before someone goes yeah, that's a good idea ...
kenton.simpson wrote:
Is there a way to make .each walk backwards threw the element collection?
ff2,0 is up to js1.7
On 10/6/06, Matt Stith [EMAIL PROTECTED] wrote:
i know js 1.2 does, but i think its only supported in ff 2.0
currently... but dont quote me on that.
On 10/6/06, Ⓙⓐⓚⓔ [EMAIL PROTECTED] wrote:
interesting!
When would length be undefined on an JQ object?
When I
14 matches
Mail list logo