JQuery Tooltipster插件在html内容中不显示带有超链接的工具提示
JQuery Tooltipster plugin does not show the tooltip with a hyperlink in the html content
我按照官方文件的指示:
http://iamceege.github.io/tooltipster/htmlcontentalt
一切正常。我在内容中添加的唯一额外的东西是一个'a'标记,如下所示:
下面是html代码:
<a class="tooltip-container">
This div has a tooltip with HTML when you hover over it!
<span class="tooltip_content">
<a href="#"></a><img src="myimage.png" /> <strong>This is the content of my tooltip!</strong>
</span>
</a>
下面是JavaScript代码:
$('.tooltip-container').tooltipster({
functionInit: function (instance, helper) {
var content = $(helper.origin).find('.tooltip_content').detach();
instance.content(content);
}
});
这是JSFiddle:
https://jsfiddle.net/c3ddf8bm/7/不幸的是,工具提示什么也没有显示!
注意:我在最新版本的Chrome和IE中进行了测试。
更新:
跟随xorspark和Josh Whitlow的问题,我意识到这个问题只有在主"tooltip-container"本身是超链接时才会发生。我认为将其定义为一个超链接或另一个标签是有意义的,客户端可以使用键盘来关注它,否则我认为它会有可访问性问题。
您的问题是在您的锚中有一个嵌套的锚。虽然这个可能是可能的,但我强烈建议删除内部锚标记,或者只使用内部锚标记并使容器成为span。
正如在这篇文章中看到的,即使你设法让它工作,它仍然会在子锚出现之前关闭父锚,这可能是导致工具提示停止工作的原因。
HTML:<div class="tooltip_templates">
<a class="tooltip-container">
This div has a tooltip with HTML when you hover over it!
<span class="tooltip_content">
<img src="myimage.png" /> <strong>This is the content of my tooltip!</strong>
</span>
</a>
Javascript: $(document).ready(function() {
$('.tooltip-container').tooltipster({
functionInit: function (instance, helper) {
var content = $(helper.origin).find('.tooltip_content').detach();
instance.content(content);
}
});
});
包含的文件:
- https://github.com/iamceege/tooltipster
- https://developers.google.com/speed/libraries/
跟随Josh Whitlow对嵌套锚的关注,我想我找到了一个解决方案:
我们应该在tooltip-container之外定义"tooltip_content"吗?
下面是html代码:
<div class="tooltip-parent">
<a class="tooltip-container">
This div has a tooltip with HTML when you hover over it!
</a>
<span class="tooltip_content">
<a href="#"></a><img src="myimage.png" /> <strong>This is the content of my tooltip!</strong>
</span>
</div>
下面是JavaScript代码:
$('.tooltip-container').tooltipster({
functionInit: function (instance, helper) {
var content = $(helper.origin).parent().find('.tooltip_content').detach();
instance.content(content);
}
});
这是JSFiddle:
https://jsfiddle.net/c3ddf8bm/8/相关文章:
- 是否可以超链接嵌入的视频框,这样当用户点击视频时,就会显示超链接
- VBA IE单击/显示没有id或标记而不是超链接的javascript
- 如何显示网页中使用的超链接列表
- 指向电话号码的超链接,其中企业/人员的姓名显示在电话上
- 如何显示下拉 Angularjs-ui-select onclick on 超链接标签
- 单击超链接后在同一页面中显示对象
- 如何从 Web 窗体中的超链接显示 asp.net mvc 视图 asp.net
- 使用 jQuery 显示带有超链接的 Div
- 如何强制超链接显示“打开/保存”对话框,而不是在浏览器中打开它
- javascript函数可以根据移动浏览器隐藏和显示超链接
- 根据单击的超链接显示/隐藏表单
- 使用JavaScript和jQuery获取一个超链接字段/列,将数据显示为SharePoint列表中的超链接
- 打开一个方框,以显示内容时,点击超链接使用html/java脚本
- 如何使突出显示的大纲出现在leaflet.js鼠标悬停和超链接
- 防止超链接的触摸和显示悬停状态
- 无法在单击超链接时显示警报
- 如何在函数中显示带有超链接的JavaScript图像
- 如何获得显示为超链接的图像的ID
- 超链接图像不显示Chrome扩展
- 如何在React Native应用程序中显示超链接