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()+"'/>");
});
精彩评论