I would like to be able to sort a bunch of div elements on my page with the click of a button.
All of them have simple text content, for example:
<div class='sortme'> CCC </div> <div class='sortme'> AAA </div> <div class='sortme'> BBB </div> <div class='sortme'> DDD </div>
When the user clicks the button, they must be rearranged in alphabetical order. Obviously, there are several ways to do this, the most obvious is that we can get all the contents into an array, sort the array and recreate the HTML based on this.
This is an example of such a solution:
http://jsfiddle.net/hibbard_eu/C2heg/
However, this would not play well with a lot of the code that was already in use, and I was hoping I could just move the divs without doing anything destructive. Is it possible?
javascript jquery
jovan
source share