如何使用 jQuery 刪除所有 CSS 類?
若要刪除所有類,請在 removeClass() 方法中不設定任何引數。這將刪除該項的所有類。
示例
你可以嘗試執行以下程式碼,使用 jQuery 刪除所有 CSS 類
<html>
<head>
<title>jQuery Selector</title>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#button1").click(function(){
$("p").removeClass();
});
});
</script>
<style>
.red { color:red; }
.blue { color:blue; }
</style>
</head>
<body>
<p class = "red" >This is first paragraph.</p>
<p class = "blue">This is second paragraph.</p>
<button id="button1">Remove</button>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言
C++
C#
MongoDB
MySQL
Javascript
PHP