jquery - How to sort divs according to their dates or ids? -
i have these divs dates ids.
<div id="20160106"></div> <div id="20160105"></div> and on.
is there way sort them latest earliest using jquery?
use sort.
var divid = []; var sorted_arr=[]; $("div").each(function() { divid.push($(this).prop("id")); sorted_arr = divid.sort(); //divid.reverse(); }) alert(sorted_arr);// test
Comments
Post a Comment