如何用 jQuery 去除下劃線?
要使用 jQuery 從文字中去除下劃線,可以使用 jQuery 的 css() 方法。css 屬性 text-decoration 屬性與 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>
廣告資訊