teelou teelou - 13 days ago 5
jQuery Question

jquery: reverse an order

How can I reverse an order with jquery?

I tried with the suggestion like this but it won't work!

$($(".block-item").get().reverse()).each(function() { /* ... */ });


Have a look here.

I want the boxed to be rearranged like this,

18
17
16
etc


Thanks.

Answer

If you have a container around the list, it's a little easier:

$("#container").append($(".block-item").get().reverse());

http://jsfiddle.net/BhTEN/12/