Hide native tooltip using jQuery

后端 未结 11 820
南旧
南旧 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:21

    To get it out of the title, I would use the data() method:

    $(document).ready( function () {
        $('.items_with_title').each( function () {
            $(this).data('title', $(this).attr('title') );
            $(this).removeAttr('title');
        });
    });
    
    // to access it
    $(document).ready( function () {
        $('A').click( function () {
            alert($(this).data('title'));
        });
    });
    

    You could also make the selector for any item that has a title attribute:

    $('*[title]').each(...
    

提交回复
热议问题