下面的HTML在相同的DATE類中顯示日期和時間。這是不好的,因爲我想獨立地塑造他們。但我不能這樣,所以我認爲jquery可以注入來分裂它。使用jquery將HTML附加到節點
<div class="container">
<a class="title" href="http://www.example.com">Headlines Goes Here</a>
<div class="date">Jan 29, 2013 12:05:00 PM EST</div>
<div class="post">
<p>Content Goes Here</p>
</div>
</div>
我與人的幫助,希望這能與jQuery的日期類中附加來解決這樣的輸出是這樣的:
<div class="container">
<a class="title" href="http://www.example.com">Headlines Goes Here</a>
<div class="date">Jan 29, 2013</div><div class="time">12:05:00 PM EST</div>
<div class="post">
<p>Content Goes Here</p>
</div>
</div>
這是我JQUERY,到目前爲止,這是我風格爲紅色,所以我可以看到物理變化,有人可以幫助解決這個問題?我的jquery顯然是不正確的。
$(window).load(function(){
if ($(".date:contains(', 2013')").length)
this.parentNode.append(this).html("</div><div class=time style=color:red>");
});
這是我的小提琴:http://jsfiddle.net/3ZWkQ/
'this.parentNode.append(本)的.html(」