Hide native tooltip using jQuery

后端 未结 11 806
南旧
南旧 2020-12-01 05:00

Is there a way to hide the native tooltip action when a user hovers over a anchor tag with a title attribute? I don\'t want to remove it just don\'t display the nasty yellow

11条回答
  •  天命终不由人
    2020-12-01 05:23

    Here's another spin-off that you might find useful, in case you use a lightbox JS plugin that still needs the "title" attribute for title processing on the lightbox slides:

    $('a.lightbox-trigger').each(function() { // Process all lightbox trigger links
    
        $(this).mouseover(function() {
            if(!$(this).data('keep'))  // 1st time = FALSE, so make the swap
                $(this).attr('data-title', $(this).attr('title')).attr('title', '');
            $(this).data('keep', true); // Preserve value if hovered before clicked
        });
    
        $(this).mousedown(function() {
            $(this).attr('title', $(this).attr('data-title')).attr('data-title', '');
            $(this).data('keep', false); // Mark element as safe to swap again
        });
    });
    

提交回复
热议问题