var temp = new Array(); var objects = $("#some_selector").parents("li"); for(var i = 0; i < objects.size(); i++) { temp[(objects.size()-1) - i] = objects.eq(i); }
pretty sure that after that runs the temp array will contain your objects in reverse order. please correct me if i'm wrong here, trying to write this at the last minute before leaving work :) cheers Michael Lawson Development Lead, Global Solutions, ibm.com Phone: 1-276-206-8393 E-mail: mjlaw...@us.ibm.com 'Examine my teachings critically, as a gold assayer would test gold. If you find they make sense, conform to your experience, and don't harm yourself or others, only then should you accept them.' From: simshaun <simsh...@gmail.com> To: "jQuery (English)" <jquery-en@googlegroups.com> Date: 05/27/2009 05:51 PM Subject: [jQuery] Reverse a collection of jQuery elements. I need to reverse the collection jQuery returns when I use $("#some_selector").parents("li"); in order to build a path. Is this doable? It'd be nice if jQuery had a reverse() method.
<<inline: graycol.gif>>
<<inline: ecblank.gif>>