如何使用 jQuery 從文字超連結中刪除下劃線?


要使用 jQuery 刪除文字超連結中的下劃線,請使用 jQuery css() 屬性。color text-decoration 屬性值使用 none。

範例

可以嘗試執行以下程式碼,瞭解如何從文字超連結中刪除下劃線

線上演示

<html>

   <head>
      <title>jQuery Text Decoration</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {
            $('a').hover(
               
               function () {
                  $(this).css({"text-decoration":"none"});
               });
               
         });
      </script>
      <style>
       a {
           text-decoration: underline;
         }
      </style>
   </head>
   
   <body>
      <a href="#">Demo text</a>        
   </body>    
</html>

更新日期:2019 年 12 月 11 日

624 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.