Adds class(es) to all of the matched elements. Also accepts a function.
function
Optional
Name of new class.
The instance itself.
$('.pear').addClass('fruit').prop('outerHTML');//=> <li class="pear fruit">Pear</li>$('.apple').addClass('fruit red').prop('outerHTML');//=> <li class="apple fruit red">Apple</li> Copy
$('.pear').addClass('fruit').prop('outerHTML');//=> <li class="pear fruit">Pear</li>$('.apple').addClass('fruit red').prop('outerHTML');//=> <li class="apple fruit red">Apple</li>
https://api.jquery.com/addClass/
Adds class(es) to all of the matched elements. Also accepts a
function.