jQuery – Toggle CSS Class

To add or remove a class at the click of a button i.e., toggle, use the toggleClass() method in jQuery. Let us see an example wherein we add a class and set the CSS properties for background color and font color for <h1>, <h2>, and <h3> elements with the click of a button. The same button clicked again will remove the CSS we set before i.e. the class will be removed:

Output

Add Remove Toggle Class jQuery

JQuery - Remove CSS Class
jQuery - Dimension Methods
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading