尝试暂时禁用 jQuery 工具提示
$(document).tooltip( "option", "disabled", true );
当我再次尝试重新启用它们时,所有的 title
属性都消失了。我试图使用以下方法重新启用它们:
$(document).tooltip( "option", "disabled", false);
当我第一次将它设置为 disabled
到 true
时,title
属性实际上被完全删除了。
还试过:
$(document).tooltip("disable");
$(document).tooltip("enable");
它在做同样的事情......
更新
在 Jasen 和 zgr024 的帮助下找到了我自己的问题的解决方案。参见 below .
最佳答案
这似乎是 jquery 版本的一个错误,因此您需要一个变通方法来在禁用工具提示后插入 title 属性。
在需要重新启用的工具提示元素上使用类名或使用 [title]
属性选择器。
<input type="text" class="tooltip-hack" title="tooltip text" />
$("#disable").on("click", function (e) {
var tooltips = $("[title]"); // or $(".tooltip-hack")
$(document).tooltip("disable");
tooltips.attr("title", "");
});
根据您的 html 结构使用两者中破坏性最小的。
另外,您注意到所有标题属性都被删除了,因此您的工具提示要更有选择性。
// instead of
$(document).tooltip();
// use a more restrictive selector
$(".tooltip-hack").tooltip();
工作示例:jsFiddle
关于javascript - 如何在 disabled = true 后重新启用 jQuery 工具提示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24704020/