方法1.
添加:document.getElementById("id").classList.add("類名");
刪除:document.getElementById("id").classList.remove("類名");
方法2
var classVal=document.getElementById("id").getAttribute("class");
添加:document.getElementById("id").setAttribute("class",classVal.concat(" 類名"));
刪除:document.getElementById("id").getAttribute("class").replace("類名"," ");
方法3.
添加:document.getElementById("id").className+=" 類名";