如何将图像添加到jQuery工具提示 [英] how do you add an image to a jquery tooltip

查看:84
本文介绍了如何将图像添加到jQuery工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还没有看到这个确切的问题……如果已经解决,请给我指出.

I haven't seen this exact question addressed...if it has been, just please point me to it.

我正在使用jquery的ui工具提示.我有一个链接,当您将鼠标悬停在它上面时,我想显示一张图像.到目前为止,对我没有任何帮助.

I'm using jquery's ui tooltip. I have one link that when you mouseover it, I'd like to show an image. Nothing has worked for me so far.

标题中的ui代码:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

HTML:

(see <a id='riverroad' href='#' title='' >image of 1 Maple St.</a>)

代码:

$( "#riverroad" ).tooltip({ content: "<img src='./images/myimage.jpg/>" });

请告诉我我在做错什么.

Please tell me what I'm doing wrong.

推荐答案

尝试以下方法:

HTML

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

JQuery

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

请参见工作中的小提琴.

Jquery 1.9.1和JqueryUI 1.9.2当然也包括在内.顺便检查一下图像路径是否正确.

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

您告诉我您正在使用jQuery设置链接,请参见第二个工作示例:

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" />' }); 

});

这是新的小提琴

这篇关于如何将图像添加到jQuery工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆