开发者

How to wrap text with an image tag?

Basically I have a html output in the format:

开发者_如何学Python
<div class="qtip-content">http://www.urlgoeshere.com/image.jpg</div>

What I want to do is use jQuery to wrap this in an image tag so the output is

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

I have multiple instances of these on the page, and each url is different.

How can I do this?


This will handle each element on your page

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


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

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜