Is it possible to hide title when hovering image?

后端 未结 8 859
长情又很酷
长情又很酷 2020-12-21 18:30

This is my code:

\"\"

When I hover that image \"some title\" appears. Is it possib

相关标签:
8条回答
  • 2020-12-21 18:51

    Kind of hilarious that on Stack Overflow, five people can give the same answer at the same time :P

    $(function(){
        $('img').hover(function(){
            $(this).removeAttr('title');
        }, function(){
            $(this).attr('title','some title');
        });
    });
    
    0 讨论(0)
  • 2020-12-21 18:56

    It can be easily done as some answers point out, but knowing what you want to do with title, I would use a data-* custom attribute or attach the title with .data()

    <img src="image.jpg" alt="" data-title="some title" />
    

    or

    $('img').data('title', 'some title');
    
    0 讨论(0)
提交回复
热议问题