I was wondering if there is an easy way to change the CSS classes in JavaScript. I have gone through all other similar questions here and I couldn\'t find an straight-forwar
If your rules start incrementing you could extract your css to a new class and switch classes:
CSS:
.container-1{ /* A set of rules */ } .container-2{ /* A set of rules */ }
JavaScript:
element.className = element.className.replace(/container-1/, 'container-2')