Ben*_*Ben 3 jquery jquery-tools jquery-tooltip
我有一个组件,我首先分配一个工具提示mouseenter(一种懒惰的工具提示分配给组件)
我使用惰性方法,因为有许多工具提示可用的组件,我不想为所有这些组件预先分配工具提示.
$(document).delegate(".tooltipable", "mouseenter", function () {
$(this).tooltip(... options ...);
$(this).tooltip().show(); // The tooltip will not appear on first `mouseenter` so I have to explicitly show it here
});
Run Code Online (Sandbox Code Playgroud)
这很好用.我想改进它,因此不会mouseenter通过检查是否tooltip已为此组件创建工具提示来创建工具提示.
怎么办?
提前致谢!
你可以尝试这样的事情.
$(document).delegate(".tooltipable", "mouseenter", function () {
var $this = $(this);
if(!$this.data("tooltipset")){
$(this).tooltip(... options ...)
.data("tooltipset", true);
}
$(this).tooltip().show(); // The tooltip will not appear on first `mouseenter` so I have to explicitly show it here
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3203 次 |
| 最近记录: |