Check to see if any of the matched elements have the given className.
className
Name of the class.
Indicates if an element has the given className.
$('.pear').hasClass('pear');//=> true$('apple').hasClass('fruit');//=> false$('li').hasClass('pear');//=> true Copy
$('.pear').hasClass('pear');//=> true$('apple').hasClass('fruit');//=> false$('li').hasClass('pear');//=> true
https://api.jquery.com/hasClass/
Check to see if any of the matched elements have the given
className.