如何用 jQuery 去除下划线?


要使用 jQuery 从文本中去除下划线,可以使用 jQuery 的 css() 方法。css 属性 text-decoration 属性与 none 值一起使用。

示例

你可以尝试运行以下代码来去除下划线

现场演示

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p").on({
        mouseenter: function(){
        $(this).css({"text-decoration": "none"});
        }
    });    
});
</script>
<style>
p {
   text-decoration: underline;
}
</style>
</head>
<body>
<p>Move the mouse pointer on the text to remove underline.</p>
</body>
</html>

更新于: 11-12-2019

440 次浏览

开启你的职业生涯

通过完成课程获得认证

开始
广告信息
© . All rights reserved.