addClass() method in jQuery

addClass() in jQuery

This method is used to add one or more class names to the specified element.

Syntax 1


  • className - Name of one or more space-separated classes to be added.
Syntax 2


  • index - index position of the element in the set.
  • currentClass - Existing class name(s)

Example 1 - add a class

Try Yourself

Example 2 - add multiple class

Try Yourself

Example 3 - add class with function

Try Yourself