qTip (jQuery plug-in) how can I remove all qtips in my page?

后端 未结 10 1914
醉话见心
醉话见心 2021-02-04 00:30

I\'m using the jquery-plugin qTip. What\'s the command to destroy all tooltips in my page ?

I tried:

$(\'.option img[title], span.taxonomy-image-link-al         


        
相关标签:
10条回答
  • 2021-02-04 01:10
       if ( jQuery( '.qtip' ).length > 0 )
        {
            jQuery( "#IdElement").qtip("destroy");
        }
    
    0 讨论(0)
  • 2021-02-04 01:13

    qTip2 is newer version of this script, but I would just like to point out 1 thing.

    $(".qtip").remove();
    

    This piece of code didn't destroy all the tooltips - it simply removed their containers. All the handlers and events attached to objects which invoked the tooltips are still avaiable in browser's memory.

    In qTip to delete the tooltip and it's handler scompletely you would have to use:

    $(mytooltip).qtip("destroy");
    

    or

    $(mytooltip).qtip('api').destroy(); 
    

    In qTip2 however using this:

    $(mytooltip).remove();
    

    Would automaticaly call out the api and destroy tooltip and it's handlers completely.

    0 讨论(0)
  • 2021-02-04 01:15

    Looks buggy. I've had some luck with this, but it does not restore the original titles. I suspect destroy doesn't do that either...

    $('span.taxonomy-image-link-alter img')
        .filter(function(){return $(this).data('qtip');})
        .qtip('destroy');
    

    It seems you cannot call destroy on elements without qTip - it doesn't fail silently, but throws an exception and stops the loop.

    0 讨论(0)
  • 2021-02-04 01:17

    What about:

    $('[data-hasqtip]').qtip('destroy', true);
    

    Seems to be working with qTip2 version 3.0.2.

    0 讨论(0)
提交回复
热议问题