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

addClass() in jQuery

addClass() Method



The addClass() method is used to add one or more classes to the selected elements. To specify multiple classes within the addClass() method, just separate them using spaces like addClass(class1 class2 class3).





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 Basic

All Sections related to jQuery