How to reverse Order List in HTML using jQuery

Let’s discuss today how we can reverse an Order/Unordered List in html using jquery. We have many ways to reverse the element of any ordered/unordered list (ol or ul Tags) using jquery. Let’s use reverse() function available in jquery library.

Let’s consider we have a list of some ordered elements, say a list of some Indians cities. Now to reverse the list first we need to get that all element in an array. That we can do by using jquery’s get() method. After getting the entire available element from a list, call reverse to change the current order of the array.

Once the array is reversed, call jquery’s each() method to iterate over reversed array. Following code snippet demonstrate how you can reverse an ordered city list and re-arrange it to show to the user using each() method.

Download SourceView Online Demo

About the Author

has written 69 posts.

I Love Coding, Analyzing, Designing and doing it the right way. I am obsessed about learn anything new daily and sharing what I have learn each Day. This Blog is journey of my Zeal, going through step by step to the mountain of desire to become prefect. Google Wanna Hire me ?

Copyright © 2019 http://www.techzoo.org. All rights reserved.
Proudly powered by WordPress. Developed by 7Tech Solutions