how do you add an image to a jquery tooltip

try this one :

Html

<a id="riverroad" href="#" title="" >image of 1 Maple St.</a>

JQuery

$( "#riverroad" ).tooltip({ content: '<img src="https://stackoverflow.com/questions/15274123/yourImagePath" />' });

See the working fiddle.

Jquery 1.9.1 and JqueryUI 1.9.2 are included of course. Check if your image path is correct by the way.

Edit :
You told me that you’re setting the link with jQuery, see this second working example :

Html

<div id="content">    
</div>

JQuery

$(document).ready(function() {
   $("#content").html('<a id="riverroad" href="#" title="" >image of 1 Maple St.</a>');
   $("#content #riverroad").tooltip({ content: '<img src="http://icdn.pro/images/fr/a/v/avatar-barbe-brun-homme-utilisateur-icone-9665-128.png" />' }); 

});

Here is the new fiddle !

Leave a Comment