I have some list - it's generated in alphabetical order
<div class='list'> <ul> <li><a href="/home/fresa/Desktop/task/page.html">2011</a></li> <li><a href="/home/fresa/Desktop/task/page.html#?topic=2013">2012</a></li> <li><a href="/home/fresa/Desktop/task/page.html#?topic=2012">2013</a></li> <li><a href="/home/fresa/Desktop/task/page.html#?topic=2012">2014</a></li> </ul> </div> and I trying to reverse it from back to front:
var arr = []; arr.push($('.list ul li')); $('.list ul').html(arr.reverse()); but it steel displays in not correct order
how to fix it, and what i'm doing wrong
arr.push()is not working as you expect it to. It is pushing one jQuery object onto your array, not the 4 individual elements you expect. I added an answer below albeit after several others.