如果鼠标不在目标或工具提示上,则仅关闭工具提示 [英] Only close tooltip if mouse is not over target or tooltip
问题描述
使用 jQuery UI 工具提示,如果我超过目标,或者如果我超过工具提示本身,我想保持工具提示打开.
我想我可以使用 close 回调来查看我是否在工具提示或目标区域上方,尽管我随后必须分配另一个鼠标移出功能.
这是我的 jsfiddle:http://jsfiddle.net/Handyman/fNjFF/
$(function(){$('#target').工具提示({项目:'a.target',内容:'只是一些文本浏览'});});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"><script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script><div id="目标"><a href="#" class="target">悬停在我身上!</a><a href="#" class="target">也悬停在我身上!</a>
我现在正在研究它,看看我能想出什么.
这是我经过大量搜索和测试后得出的解决方案:http://jsfiddle.net/Handyman/fNjFF/11/
$('#target').tooltip({项目:'a.target',content: '加载中...',show: null,//立即显示打开:函数(事件,用户界面){if (typeof(event.originalEvent) === '未定义'){返回假;}var $id = $(ui.tooltip).attr('id');//关闭任何挥之不去的工具提示$('div.ui-tooltip').not('#' + $id).remove();//ajax 函数拉入数据并将其添加到工具提示到这里},关闭:函数(事件,用户界面){ui.tooltip.hover(function(){$(this).stop(true).fadeTo(400, 1);},功能(){$(this).fadeOut('400', function(){$(this).remove();});});}});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css"><script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script><身体><div id="目标"><a href="#" class="target">悬停在我身上!</a><a href="#" class="target">也悬停在我身上!</a>