jQuery – Add CSS Class

To add a class to the selected element, use the addClass() method in jQuery. We can add:

  • A single class
  • Multiple classes
  • Add a single class to different elements
  • Add multiple classes to different elements

Add a single class

We will add a single class demo here using the addClass() method in jQuery:

Output

jQuery Add a single class

Add Multiple Classes

We will add multiple classes i.e.  demo and example here using the addClass() method in jQuery:

Output

jQuery Add multiple classes

Add a single class to different elements

We will add a single class demo here to more than one element, such as <h1>, <h2>, <h3> using the addClass() method in jQuery:

Output

jQuery Add a single class to different elements

Add multiple classes to different elements

We will add multiple classes i.e.  demo and example here to different elements, such as <h1>, <h2>, <h3> using the addClass() method in jQuery:

Output

jQuery Add multiple classes to different elements

jQuery - Remove Element
JQuery - Remove CSS Class
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