如果鼠标未超过目标或工具提示,则仅关闭工具提示

使用jQuery UI工具提示,如果我超过目标,或者如果我超过工具提示本身,我想保持工具提示处于打开状态。

我想我可以使用close回调来查看我是否超过工具提示或目标区域,尽管我必须再分配另一个mouseout函数。

这是我的jsfiddle: http : //jsfiddle.net/Handyman/fNjFF/

$(function() { $('#target').tooltip({ items: 'a.target', content: 'just some text to browse around in' }); }); 
     

我现在正在研究它,看看我能想出什么。

这是我经过大量搜索和测试后提出的解决方案: http : //jsfiddle.net/Handyman/fNjFF/11/

 $('#target').tooltip({ items: 'a.target', content: 'Loading…', show: null, // show immediately open: function(event, ui) { if (typeof(event.originalEvent) === 'undefined') { return false; } var $id = $(ui.tooltip).attr('id'); // close any lingering tooltips $('div.ui-tooltip').not('#' + $id).remove(); // ajax function to pull in data and add it to the tooltip goes here }, close: function(event, ui) { ui.tooltip.hover(function() { $(this).stop(true).fadeTo(400, 1); }, function() { $(this).fadeOut('400', function() { $(this).remove(); }); }); } }); 
       

这是div元素的简单解决方案:

 $(function() { $("#mydiv").tooltip({ effect: 'slide', content: 'loading...', open: function (event, ui) { $(ui.tooltip).appendTo(this); } }); }); 

http://jsfiddle.net/4YDGp/10/

它不是内置的,因为他们jQuery UI团队并不认为它会增加价值。 您可以在此处阅读function请求。 有一些像这样的项目( 演示 )的链接,添加你正在寻找的效果。

您可以使用最小插件执行此操作:

$('[title|=ptooltip]').pTooltip();

或者你可以查看qTip或其他更强大的插件。

我有一个类似的目标,即使用HTML链接保持打开的引导工具提示,直到单击其他位置或打开另一个工具提示(因此用户可以单击工具提示中的链接)。

以下是基于之前一些post的解决方案:

 /** * For tooltips with links, don't remove hover until click somewhere else or open another tooltip */ $(function() { // Show tooltip with html link $('#tip').on("mouseover", function() { $('#tip').tooltip('show'); }); // If open any other tooltip, close the one with the link. $('[rel="tooltip"]').not('#tip').on("mouseover", function() { $('#tip').tooltip('hide'); }); // If click any where hide tooltip with link $(document).click(function() { $('#tip').tooltip('hide'); }); }); 

看起来像这样的HTML。 关键是使用HTML将数据触发器设置为“”。

  Linked ToolTip  

的jsfiddle