gpt4 book ai didi

jquery - 如何将图像添加到 jquery 工具提示

转载 作者:行者123 更新时间:2023-12-03 22:00:37 26 4
gpt4 key购买 nike

我还没有看到这个确切的问题得到解决...如果有,请指出它。

我正在使用 jquery 的 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/>" });

请告诉我我做错了什么。

最佳答案

试试这个:

HTML

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

JQuery

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

查看工作fiddle .

当然包括 Jquery 1.9.1 和 JqueryUI 1.9.2。顺便检查一下你的图片路径是否正确。

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

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

});

这是新的fiddle !

关于jquery - 如何将图像添加到 jquery 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15274123/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com