如何将 HTML 添加到 jQuery 工具提示?
我正在尝试在我的页面上设置工具提示。列表中有 7 个链接,全部都有工具提示。其中 6 个仅使用基本设置,但其中一个需要使用更大的背景图像并具有自定义 HTML。当我尝试配置此功能时,6 个基本工具提示有效,但 1 个较大的 HTML 工具提示没有任何反应。
这是我的代码:
<tr><td>
<a class="text_link" title="Tooltip text">Dental Insurance Providers</a>
</td></tr>
<tr><td>
<a class="text_link" id="health_insurance_tooltip" >Health Insurance Providers</a>
<div class="tooltip">
<a href="#">This is my html tooltip</a>
</div>
</td></tr>
<script type="text/javascript">
// initialize tooltip
$("[title]").tooltip({
position: "top left",
effect: 'slide',
opacity: 1,
offset: [15, 190],
tipClass: 'small_tooltip'
});
$("#health_insurance_tooltip").tooltip({
position: "top left",
effect: 'slide',
opacity: 1,
offset: [15, 190]
});
</script>
<style type="text/css">
/* tooltip styling */
.small_tooltip {
display:none;
background:url(/fcapps/images/tooltip/white_arrow.jpg);
font-size:12px;
height:70px;
width:160px;
padding:25px;
color:#255E0D;
opacity:1 !important;
}
.tooltip {
display:none;
background:url(/fcapps/images/tooltip/white_arrow_big.png);
font-size:12px;
height:70px;
width:160px;
padding:25px;
color:#255E0D;
opacity:1;
}
</style>
任何帮助将不胜感激。
I am trying to setup tooltips on my page. There are 7 links in a list that all have tooltips. 6 of these just uses the basic setup but one of them needs to use the larger background image and have custom HTML. When I try to configure this the 6 basic tooltips work but nothing happens for the 1 larger HTML one.
Here is my code:
<tr><td>
<a class="text_link" title="Tooltip text">Dental Insurance Providers</a>
</td></tr>
<tr><td>
<a class="text_link" id="health_insurance_tooltip" >Health Insurance Providers</a>
<div class="tooltip">
<a href="#">This is my html tooltip</a>
</div>
</td></tr>
<script type="text/javascript">
// initialize tooltip
$("[title]").tooltip({
position: "top left",
effect: 'slide',
opacity: 1,
offset: [15, 190],
tipClass: 'small_tooltip'
});
$("#health_insurance_tooltip").tooltip({
position: "top left",
effect: 'slide',
opacity: 1,
offset: [15, 190]
});
</script>
<style type="text/css">
/* tooltip styling */
.small_tooltip {
display:none;
background:url(/fcapps/images/tooltip/white_arrow.jpg);
font-size:12px;
height:70px;
width:160px;
padding:25px;
color:#255E0D;
opacity:1 !important;
}
.tooltip {
display:none;
background:url(/fcapps/images/tooltip/white_arrow_big.png);
font-size:12px;
height:70px;
width:160px;
padding:25px;
color:#255E0D;
opacity:1;
}
</style>
Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将 html 嵌入到标题标签中,而不是将其作为独立的 div。这有点不方便,因为您必须转义 HTML 中出现的任何引号,但它对我有用。因此将: 替换
为:
Try embedding the html in the title tag rather than having it as a standalone div. It's a little inconvenient since you have to escape any quotes that appear in your HTML, but it has worked for me. So replace:
With: