如何使用 jQuery 刪除下劃線?


若要在 jQuery 中從文字中刪除下劃線,請使用 jQuery css() 方法。text-decoration 屬性的 css 屬性與 none 值一起使用。

示例

你可以嘗試執行以下程式碼來刪除下劃線

線上演示

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/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>

更新於: 2019 年 12 月 11 日

440 瀏覽量

開啟你的職業生涯

完成課程後獲得認證

開始
廣告
© . All rights reserved.