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...
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...
You could to it like this:
$($("li")
.get()
.reverse())
.each(function() {
// some code
});