Tuesday, December 4, 2012

jQuery code to reverse ordered list child elements

In this short post, Find best method to reverse the order of child element on an ordered list using jQuery.
$(document).ready(function() {
    $("#btnReverse").click(function() {
        var list = $('ol');
        var listItems = list.children('li');
        list.append(listItems.get().reverse());
    });
});​​​​​​​
See result below


Feel free to contact me for any help related to jQuery, I will gladly help you.