如何使用 jQuery 刪除所有 CSS 類?
要使用 jQuery 刪除所有 CSS 類,請使用 removeClass() 方法,不帶引數。
示例
可以嘗試執行以下程式碼來刪除類
<html> <head> <title>jQuery Example</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> $(document).ready(function() { $("p").removeClass(); }); </script> <style> .red { color:red; } .green { color:green; } </style> </head> <body> <p class = "red" >This is first paragraph.</p> <p class = "green">This is second paragraph.</p> </body> </html>
廣告