qTip(jQuery插件)如何删除页面中的所有qtips?

ane*_*yzm 23 javascript jquery jquery-plugins qtip

我正在使用jquery-plugin qTip.在我的页面中销毁所有工具提示的命令是什么?

我试过了:

$('.option img[title], span.taxonomy-image-link-alter img[title]').qtip("destroy");
Run Code Online (Sandbox Code Playgroud)

但它没有用......谢谢

ane*_*yzm 25

我已经解决了 $(".qtip").remove();

  • 通过此选择器删除不会清除绑定到目标元素的任何资源. (3认同)

bip*_*obe 19

qTip2是这个脚本的新版本,但我想指出一件事.

$(".qtip").remove();
Run Code Online (Sandbox Code Playgroud)

这段代码没有破坏所有的工具提示 - 它只是删除了他们的容器.附加到调用工具提示的对象的所有处理程序和事件仍然可以在浏览器的内存中使用.

在qTip中删除工具提示和它的处理程序scompletely你必须使用:

$(mytooltip).qtip("destroy");
Run Code Online (Sandbox Code Playgroud)

要么

$(mytooltip).qtip('api').destroy(); 
Run Code Online (Sandbox Code Playgroud)

在qTip2中使用此:

$(mytooltip).remove();
Run Code Online (Sandbox Code Playgroud)

会自动调出api并彻底销毁工具提示和它的处理程序.

  • +1删除容器也会破坏内部的任何元素,而不仅仅是悬停工具提示. (2认同)

Ste*_*wie 16

$('.qtip').each(function(){
  $(this).data('qtip').destroy();
})
Run Code Online (Sandbox Code Playgroud)


gam*_*ela 11

qtip("destroy") 有缺陷(版本2.1.1)并没有清除一切.

我发现这是一个正确的解决方法:

// don't call destroy if not needed
if (element.data("qtip")) {
    // the 'true' makes the difference
    element.qtip("destroy",true);
    // extra cleanup
    element.removeData("hasqtip");
    element.removeAttr("data-hasqtip");
}
Run Code Online (Sandbox Code Playgroud)