jQuery: How to remove the tipsy tooltip?

前端 未结 9 1778
盖世英雄少女心
盖世英雄少女心 2021-01-08 01:17

I add the tipsy tooltip to divs with the .placeTaken class. The user can then drag boxes around, so I remove the class and add it to a new div instead. When this happens, I

相关标签:
9条回答
  • 2021-01-08 01:47

    Using $(".tipsy").remove(); seems to do the trick since a div with a tipsy class is appended to the body of the doc when the tooltip is shown.

    Just be sure you don't use a tipsy class elsewhere (i.e. call your tooltip's something like toolTip instead)

    0 讨论(0)
  • 2021-01-08 01:52

    If you don't want the tipsy to show anymore just use .tipsy('disable') on the element.

    If you are using trigger: manual and you want to hide it you can just remove the .tipsy div on the body.

    There's also disable enable and toggleEnabled

    0 讨论(0)
  • 2021-01-08 02:02

    I saw this question after Googling a situation to disable Tipsy when on a mobile device due to complexities with the touch/click event, specifically on iPads.

    The solution I decided to implement was adding a small test at the top of the jquery.tipsy.js file.

    To disable Tipsy on touch (mobile) devices: var deviceAgent = navigator.userAgent.toLowerCase();

    var isTouchDevice = Modernizr.touch ||
    (deviceAgent.match(/(iphone|ipod|ipad)/) ||
    deviceAgent.match(/(android)/) ||
    deviceAgent.match(/(iemobile)/) ||
    deviceAgent.match(/iphone/i) ||
    deviceAgent.match(/ipad/i) ||
    deviceAgent.match(/ipod/i) ||
    deviceAgent.match(/blackberry/i) ||
    deviceAgent.match(/bada/i));
    
    function Tipsy(element, options) {
        this.$element = $(element);
        this.options = options;
        this.enabled = !isTouchDevice;
        this.fixTitle();
    };
    

    See: The best way to detect if user agent supports touch

    0 讨论(0)
  • 2021-01-08 02:03

    Easier way im using:

    $('body').find('.tipsy').each(function(){
        $(this).remove();
    });
    
    0 讨论(0)
  • 2021-01-08 02:06

    I recently had this issue, here's how I resolved it:

    Use this to set the original-title attribute to 'stop':

    $('.myElement').attr('original-title','stop');
    

    Then, in jquery.tipsy.js, change the code to the following:

    ...
    } else if (typeof opts.title == 'function') {
        title = opts.title.call(this);
    }
    
    if (title != 'stop') {    //line 32
        ...
        ...
    }                         //line 62
    ...
    

    In my release (0.1.7) the added code starts at line 32 and ends bracket at line 62. Tipsy should see that your title attribute equals 'stop' and wont try to open the tooltip.

    Also, this spits out some error to the console. It doesn't make any difference, but if you want to get rid of it, add this at line 73 (after adding previous code)

    try { tip.remove(); } catch(err){}
    

    POW

    0 讨论(0)
  • 2021-01-08 02:07
    $("#"+dropFromId)[0].setAttribute('original-title', '')
    
    0 讨论(0)
提交回复
热议问题