jQuery addClass() Method
jQuery addClass() Method
The addClass() method is used to add one or more class names to the selected elements. We cannot use it to remove existing class attributes. It is only used for adding one too many class names. For multiple class names, we have to separate them with commas.
Syntax:-
Its syntax is:- $(selector).addClass(classname, function(index, currentclass))
Further Explanation:-
Parameter | Description |
---|---|
classname | Required. Specifies one or more class names to be added |
function(index,currentclass) | Optional. Specifies a function that returns one or more class names to be added
|