I am using JavaScript and I want to add/remove a Class attribute if a button is clicked. I am able to add the class, but I don\'t know how to remove it. how can I do that?
In the future-ish, you can also consider Element.classList.
var d = document.getElementsByTagName('div')[0];
d.classList; // []
d.classList.add('foo'); // undefined
d.classList; // ["foo"]
d.classList.remove('foo'); // undefined
d.classList; // []
I say future-ish b/c you have to consider this IE < 10.