Here’s how you can change an element’s class using jQuery

When you need to add a class name to an element using jQuery, you can use the addClass() method.

The addClass() method can accept multiple class names as its parameter, separated by a space:

addClass("newClass otherClass"); 
// adds newClass and otherClass to all matching elements

The addClass() method can be used together with the removeClass() method so you can change elements’ classes from one another.

#jquery #javascript

How to Change an Element's Class with jQuery
2.55 GEEK