I've been trying to use jQuery to have a button function reverse the order of a <ul>
.
For some reason the code completely messes up with the styling of the ul when clicked. It might be because of the lazy loader I'm using for the images (qazy.js), but I'm not entirely sure. It just seems to break the <ul>
.
You can see the live code here: http://designers.watch/tester.html
You'll see the undesirable effect when you click the 'Reverse Order' button.
The code I use the reverse the <ul>
is:
$(document).ready(function(){
$("#rev").click(function(){
var list = $("ul li").get().reverse();
$("ul").empty();
$.each(list, function(i){
$("ul").append("<li>"+list[i].innerHTML+"</li>");
});//each
});//function
});//ready
The two issues are:
- The styles get messed up.
- The lazy loader won't load the images that have been brought to the top of the list from the reverse ordering.
Is there a way that I can fix these issues? Should I use a different lazy loader script?
Thanks in advance to anyone who helps out.
` somewhere online. Are you suggesting that I use other code to reverse the `
– javinladish Dec 27 '14 at 20:19` order?