当您单击它的 hot* 元素时,如何使您的工具提示永远保持不变,就像一个粘性一样,并在您再次单击它时返回正常行为?
* = 触发工具提示的元素
问问题
152 次
1 回答
0
这意味着您必须取消绑定 mouseleave 事件并在交替单击时重新绑定它。通过变量交替点击,例如tipsyStick。mouseleave 的问题是我们不知道原始事件。在主要的小费代码中搜索了一下,这是调用小费离开函数的方法:$(this).tipsy().leave
如果 $(this) 是热点区域。
工作代码:
$('.tooltip')
.click(function() {
/*Sticky and back on click*/
//Remember status (and already reverse here, so also defined)
this.tipsyStick=!this.tipsyStick;
//Bind or rebind depending on status
if (this.tipsyStick)
$(this).unbind('mouseleave');
else
$(this).bind('mouseleave', $(this).tipsy().leave);
})
//General tipsy triggering
.tipsy();
请注意,虽然tipsy 可能已经通过live()
而不是绑定它bind()
,这取决于您的初始选项。die
在这种情况下,请分别使用和相应地更改 mouseleave 方法live
。
于 2014-07-30T19:17:20.810 回答