hasClass()

hasClass(classname) : Boolean

Returns true if the HTML element or the first element in a result set has the specified class.

classname

String containing one class name.

Example

This script checks if the first of the results (the set of elements matching the selector of the script) has the class 'green'. If so, it colors the text of all the elements in the results green.

if (results.hasClass('green')) {
	results.css('color', 'green');
}