请帮助。我只看到DATA和TIME,但是对于我需要更多信息:管理员 - 添加在网站上推荐其Feed。
<div id="D">
<div><div class="dateDiv">2015-12-11 02:45:12</div> Admin - Add Comment</div>
<div><div class="dateDiv">2015-12-11 02:49:12</div> Admin - Add Comment</div>
<div><div class="dateDiv">2015-12-11 02:50:12</div> User - Add Comment</div>
<div><div class="dateDiv">2015-12-11 03:39:32</div> Moderator - Add Comment</div>
</div>
脚本:
<script>
var elems = $.makeArray($(".dateDiv"));
elems.sort(function(a, b) {
return new Date( $(a).text() ) < new Date( $(b).text() );
});
$("#D").html(elems);
</script>
答案 0 :(得分:0)
您可以将脚本更改为:
var elems = $.makeArray($("#D").children());
elems.sort(function(a, b) {
return new Date( $(a).find('.dateDiv').text() ) < new Date( $(b).find('.dateDiv').text() );
});
$("#D").html(elems);