我需要在评论日期低于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>
这可能吗?
通常情况下,您应该显示到目前为止所做的尝试。
有一种方法:
$(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>');
}
});
});
演示:http://jsfiddle.net/36bg4/2/