I have a set of divs with random ids:
<div id="container">
<div id="2"></div>
<div id="9"></div>
<div id="7"></div>
<div id="1"></div>
<div id="4"></div>
</div>
Is there a fast way to sort them according to their id values using jQuery? Thank you.
I'd use the tinysort plugin:
http://tinysort.sjeiti.com/
In your case it would be something like:
$("#container > div").tsort("",{attr:"id"});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With