I have divs with data attribute data-submit-date and i want to sort them based on the value of this attribute which is date format.
here's the code for one of the divs:
<div class="article" data-submit-date="2017-09-12T05:45:36.951Z">
<h1>aaaaA</h1>
</div>
my attempts:
$divss = $(".article");
var alphaOrderDivs = $divss.sort(function (a, b) {
return $(a).data("submit-date") > $(b).data("submit-date");
});
$(".articles").html(alphaOrderDivs);
I replaced this line $(a).data("submit-date") with Date.parse($(a).data("submit-date")) but it fails. Can anyone help me?
Thank In Advance