addClass() 向元素添加一个或多个class
<div>Always believe that good things are going to happen</div>
<p>Always believe that good things are going to happen</p>
<script>
$('div').addClass('one tow three');
$('p').addClass('four');
</script>
![](https://images2018.cnblogs.com/blog/1321525/201809/1321525-20180908110526744-1584711514.png)
removeClass() 删除class
<div class="one two three">Always believe that good things are going to happen</div>
<p class="four five">Always believe that good things are going to happen</p>
<script>
$('div').removeClass();
$('p').removeClass('four');
</script>
![](https://images2018.cnblogs.com/blog/1321525/201809/1321525-20180908110752506-1765665478.png)
toggleClass() 添加或删除切换
<div class="one two three">Always believe that good things are going to happen</div>
<p class="four">Always believe that good things are going to happen</p>
<script>
$('div').toggleClass('one css');
$('p').toggleClass('four');
</script>
![](https://images2018.cnblogs.com/blog/1321525/201809/1321525-20180908111048619-1513729685.png)