如何使用 jQuery 在滑鼠懸停時給超連結加下劃線?
要使用 jQuery 在滑鼠懸停時給超連結加下劃線,請使用 jQuery css() 屬性。顏色 text-decoration 屬性已用於上述程式碼中。
示例
您可以嘗試執行以下程式碼以瞭解如何給超連結加下劃線
<html> <head> <title>jQuery Hyperlink Decoration</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $('a').hover( function () { $(this).css({"text-decoration":"underline"}); }); }); </script> <style> a { text-decoration: none; } </style> </head> <body> <a href="#">Demo text</a> </body> </html>
廣告