2010-12-16 43 views
0

基本上我有如下格式的HTML輸出:文本換行與圖片標籤 - jQuery的

<div class="qtip-content">http://www.urlgoeshere.com/image.jpg</div> 

我想要做的就是使用jQuery在圖像標籤來包裝這個什麼所以輸出

<div class="qtip-content"><img src="http://www.urlgoeshere.com/image.jpg" /></div> 

我有這些在頁面上的多個實例,並且每個url是不同的。

我該怎麼做?

非常感謝, 克里斯

回答

4

這將處理每個元素的網頁

$(".qtip-content").each(function() { 
    $(this).html("<img src='" + $(this).html() + "' />"); 
} 
1
$('.qtip-content').each(function(){ 
    $(this).html("<img src='"+$(this).html()+"'/>"); 

}); 
+0

拍上提交... :( – FatherStorm 2010-12-16 21:35:02

+0

+1我在年輕的花了打字班年齡 – hunter 2010-12-16 21:41:12