jQuery Intro

jQuery Intro Quiz

jQuery Intro Exercise

jQuery Basic

jQuery Basic Quiz

jQuery Basic Exercise

jQuery Advance

jQuery Advance Quiz

jQuery Advance Exercise

jQuery Selectors

jQuery Effects

jQuery Events

jQuery Methods and Properties

jQuery Traversing

jQuery CSS and HTML Methods

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.




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
  • index - Returns the index position of the element in the set
  • currentclass - Returns the current class name of the selected element

Code Explanation

All Tutorials related to jQuery CSS and HTML Methods

All Sections related to Jquery