How to manage css in jQuery?
Add new Class to an Element
addClass(): This method adds one or more classes to the selected elements.
You can also add multiple classes to the selector. Syntax:$(selector).addClass(class1, class2);
Remove Existing class from an element
removeClass(): Similar to adding class, you can also remove the classes from the elements by using this method. The removeClass() method can remove a single class, multiple classes, or all classes at once from the selected elements.
For removing one class: $(selector).removeClass(class1);
For removing multiple class: $(selector).removeClass(class1, class2, class 3);
For removing all classes at once: $(selector).removeClass()
Toggle Existing Class
toggleClass(): This method is used for adding or removing one or more classes from the selected elements in such a way that if the selected element already has the class, then it is removed. Else if an element does not have the specified class, then it is added i.e. it toggles the application of classes.