// use the classList API to remove and add classes div.classList.remove("foo"); div.classList.add("anotherclass");