js style element with class code example
Example 1: change elements class javascript
document.getElementById("MyElement").classList.add('MyClass');
document.getElementById("MyElement").classList.remove('MyClass');
if ( document.getElementById("MyElement").classList.contains('MyClass') )
{
document.getElementById("MyElement").classList.toggle('MyClass');
}
Example 2: js add style to each class
var all = document.getElementsByClassName('someClass');
for (var i = 0; i < all.length; i++) {
all[i].style.color = 'red';
}