document.getElementById("id").classList.add("yourdiv")
删除可以用document.getElementById("id").classList.remove("yourdiv")
this.className='yourdiv';//这是把class设置为yourdiv
this.className+=' '+'yourdiv';//这是在当前div上添加class
this.setAttribute("class","yourdiv");
document.getElementById("myDIV").classList.add("mystyle");
this.className += " yourdiv";