Add CSS Class to Each Matching Element .addClass()

.addClass(className)

className: {CSS class, Function(index, currentClass){...}}
e.g. $("div").addClass("className")

.addClass(className) will add className to class attribute of each element in the matched set.

Example 1: $("div").addClass("someClass") will add someClass to class attribute of each <div> i.e. class='someClass' .
Before
<div></div>
<div class="anotherClass"></div>
After
<div class="someClass"></div>
<div class="anotherClass someClass"></div>
Example 2: $("div").addClass( function(index, currentClass) { return currentClass+"-"+index ;} ) will add currentClass+"-"+index to class attribute of each <div> i.e. class='a a-0'.
Before
<div class="a"></div>
<div class="b"></div>
After
<div class="a a-0"></div>
<div class="b b-1"></div>
jQuery manipulation css .addClass()