jQuery addClass()

The jQuery addClass() method adds one or more class name to the selected element.




  • Classname is a compulsory parameter of jQuery addClass() method, as it specifies the class names to be added.


  • It is an optional parameter.
  • The function parameter is used to return the property‚Äôs class names to be added.


  • Index is an argument passed within the function.
  • It is used to give an index position to an element in the set.


  • This parameter returns the current class name of the selected element.

Example 1

<!DOCTYPE html>  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>    
.yo {  
	font-size: 250%;  
	color: red;  
<p>How are you?</p>  
<p>Nice to see you again.</p>  
<button>Click me</button>  

Try it

JS Bin on jsbin.com

Content Protection by DMCA.com
Please Share