hasClass()

hasClass(classname) : Boolean

Returns true if the first element in this 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');
}
 
  • Last Topic Update: 19, February, 2018 12:18 PM
  • Last Published: 23, May, 2019 01:55 PM