如何让 jQuery Beauty Tip 在光标位于工具提示文本上方时保持打开状态?
我正在使用 jQuery 美容技巧 (它也使用 hoverIntent 插件),我想在工具提示文本内显示一个 href 链接并允许用户单击该链接。
但是,一旦我们离开锚点,提示文本就会在超时(我们可以定义)后消失,
所以只要用户光标位于锚点或工具提示文本上,我就希望保持工具提示文本打开。
我怎样才能做到这一点?这可能吗?我尝试过,但没有成功,类似:
$('.bt').bt({
postShow: function(box) {
$(".bt-content").hoverIntent({
timeout : 500,
over: function() {
$(".bt-wrapper").show(); //or $(".bt-active").btOn();
}
});
}
})
I am using jQuery beauty tips (which is also using hoverIntent plugin) and I would like to display an href link inside the tooltip text and allow the user to click on the link.
However, as soon as we leave the anchor, the toottip text disappears after some timeout (that we can define)
So I would like to keep the the tooltip text opened as long as the user cursor is over the anchor OR the tooltip text.
How can I do that? Is it possible? I tried, without success, something like:
$('.bt').bt({
postShow: function(box) {
$(".bt-content").hoverIntent({
timeout : 500,
over: function() {
$(".bt-wrapper").show(); //or $(".bt-active").btOn();
}
});
}
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是可能的。以下解决方案使用 jQuery 1.7 和hoverIntent r5。我在 Chrome、Safari、FF 3.7、FF 7 和 IE8 中进行了测试。
我再次使用hoverIntent,这次是在BeautyTip 框中,设置一个标志(“data-hasmouse”),指示鼠标光标是否仍悬停在工具提示上。只要设置了该标志,新的 hideTip 方法就不会执行任何操作。相反,当 BeautyTip 框自己的“hoverIntent out”触发时,它会被隐藏。
It is possible. The following solution works using jQuery 1.7 and hoverIntent r5. I tested it in Chrome, Safari, FF 3.7, FF 7 and IE8.
I used hoverIntent again, this time on the BeautyTip box, to set a flag ("data-hasmouse") indicating whether the mouse courser is still hovering over the tooltip. As long as the flag is set, the new hideTip method will do nothing. Instead, the BeautyTip box is hidden when its own "hoverIntent out" fires.
这是迄今为止我能做的最好的事情:
将这些代码添加到提示的选项中。
它可以工作(至少在 Firefox 上),但我更喜欢使用悬停意图。
This is the best I could do so far:
Add these code on the option of the tip.
It works (at least on Firefox) but I would prefer to use the hoverintent.
您好,感谢 Chris Cinelli 的上述回复。然而,上述解决方案的问题是,当我们离开锚点时,工具提示仍然存在,只有在页面外单击才会触发其关闭。
然而,这种行为似乎不正确,因为如果鼠标悬停时弹出工具提示,那么鼠标悬停时也应该消失(如果行为是在鼠标悬停时定义的)。
因此,为了实现这种行为,我对 chris cinelli 提供的解决方案进行了额外的更改。
解决方案:
我已为外部容器定义了一个虚拟类 toolTipRange,其中弹出窗口的外观有效,并在 post show 事件
$(".toolTipRange").bind('mouseleave',function(event) {< br>
if(event.latedTarget.nodeName != "CANVAS") {
that.btOff();
}
});
Hi thankx Chris Cinelli for the above reply. However the problem with the above solution is the tooltip remains as we move out of anchor, and only a click outside the page will trigger its closure.
However the behaviour seems to be improper, because if tooltip popups on mouse over then should also disappear onmouseout (if the behavious is defined on mouse over so).
So to achieve that behaviour i had done additional changes to that of the solution provided by chris cinelli.
Solution :
I have defined a dummy class toolTipRange to the outer container within which appearance of popup is valid and added the following code in the post show event
$(".toolTipRange").bind('mouseleave',function(event) {
if(event.relatedTarget.nodeName != "CANVAS") {
that.btOff();
}
});