添加: obj.classList.add("active");
删除:obj.classList.remove("active");例子
<button class="btn1 btn2">点击</button> <script> var btn=document.querySelector(".btn1"); btn.onclick=function(){ this.classList.remove("btn2") } </script>