2

Possible Duplicate:
JQuery .each() backwards

With Jquery, how can I iterate from bottom to top ?

For example, I have this list:

<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>

I want to get item 3, then item 2 and then item 1...

Community
  • 1
  • 1
PJ Bergeron
  • 2,788
  • 4
  • 25
  • 42
  • 2
    I believe this is similar to: http://stackoverflow.com/questions/9182654/does-jquery-always-iterate-through-doms-in-order-in-which-they-are-found-in-the – Maude Aug 24 '12 at 13:47

1 Answers1

6

You could to it like this:

$($("li")
        .get()
        .reverse())
        .each(function() {
         // some code

         });
mas-designs
  • 7,498
  • 1
  • 31
  • 56