102
jQuery addClass()
The addclass() method is used to add one or more class name to the selected element. This method is used only to add one or more class names to the class attributes not to remove the existing class attributes.
If you want to add more than one class separate the class names with spaces.
Syntax:
Parameters of jQuery addClass() method
Parameter | Description |
---|---|
Classname | It is a mandatory parameter. It specifies one or more class names which you want to add. |
Function (index, currentclass) | It is an optional parameter. It specifies a function that returns one or more class names to be added.
|
Example of jQuery addClass() method
Let?s take an example to demonstrate the effect of jQuery addclass() method:
Next TopicjQuery hasClass()