我需要在评论日期低于2014年4月时显示HTML。这是我的wordpress日期代码
<time datetime="2014-05-26T12:19:33+00:00">May 26, 2014 at 12:19 pm</time>
我想显示以下HTML
<p class="comment-rating"> <img src="#"><br>Rating: <strong>5 / 5</strong></p>
这可能吗?
答案 0 :(得分:3)
通常你应该展示你到目前为止尝试过的尝试。
这是一种方法:
$(function () {
var checkDate = new Date("2014-05-01");
$.each($("time"), function () {
var $timeItem = $(this);
var currentDate = new Date($timeItem.attr("datetime"));
if (currentDate < checkDate) {
$timeItem.after('<p class="comment-rating"> <img src="#"><br>Rating: <strong>5 / 5</strong></p>');
}
});
});