使用CSS悬停时删除图像标题?

anh*_*g95 6 css

HTML代码

<a href="#page5"><img id="imgsrc_4" src="http://140.123.105.162:4001/h/8427d242759e6584152dc293579042b3f9c377a5-254818-1200-1677-jpg/keystamp=1441340100-47d38eef85/002.jpg" title="002.jpg" style="margin: 0px; width: 1050px; height: 1467px;"></a>
Run Code Online (Sandbox Code Playgroud)

有很多像上面这样的 HTML 图像。我想搜索图像的标题 (001.jpg,002.jpg,...) 并使用 CSS 删除/隐藏它。

我怎样才能做到这一点?

小智 9

有点晚了,但如果有人遇到同样的问题:

您可以pointer-events:none在该图像上使用,因此链接仍然有效,但标题不会在悬停时显示


小智 3

你可以使用 jquery 来做到这一点。您需要添加类,并在该类的基础上,您必须使用 jquery 隐藏,这里是演示..

$(".img_bx").hover(function(){
 
        // Get the current title
        var title = $(this).attr("title");
 
        // Store it in a temporary attribute
        $(this).attr("tmp_title", title);
 
        // Set the title to nothing so we don't see the tooltips
        $(this).attr("title","");
         

    });
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<a href="#page5"><img class="img_bx" id="imgsrc_4" src="https://angularjs.org/img/angularconnect-conf.png" title="002.jpg" style="margin: 0px; width: 120px; height: 120px;"></a>
Run Code Online (Sandbox Code Playgroud)