【发布时间】:2017-10-19 06:26:13
【问题描述】:
我正在使用 jQuery 在我的页面上具有“详细信息”属性的每个链接上显示工具提示
$(function() {
$tooltip = $(document).tooltip({
show: false,
track: true,
items: "a[data-details]",
content: function() {
return $( this ).data('details');
}
});
});
这很好用。但是,当用户单击其中一个链接时,URL 会在新选项卡中打开(使用 target="_blank")。问题是当用户返回第一个选项卡时,工具提示仍然打开。
到目前为止,这是我尝试过的:
$('a[data-details]').on('click mousedown mouseup', function() { // this might be overkill
$(document).tooltip("close"); // Doesn't work at all
$('div[class^="ui-tooltip"]').remove(); // removes the tooltip onclick, but gets it back opened when returning on the tab
});
有没有办法在打开新页面时保持工具提示关闭?
感谢您的帮助。
这是一个说明问题的小提琴:https://jsfiddle.net/su4v757a/
注意:我将 jQuery 1.12.4 与 jQueryUI 1.12.1 一起使用
【问题讨论】:
标签: javascript jquery html jquery-ui tooltip