hasClass() removeClass() addClass()

   //检查第元素是否包含 "intro" 类

$("button").click(function(){

  alert($("p:first").hasClass("intro"));

});                  

向第一个 p 元素添加一个类:

$("button").click(function(){
  $("p:first").addClass("intro");
});

移除所有 <p> 的 "intro" 类:

$("button").click(function(){
  $("p:first").removeClass("intro");
});
原文地址:https://www.cnblogs.com/jianxingjianyuan/p/7127741.html