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: 24/01/2017 09:32
  • Last Published: 7/6/2017 : 9:49 AM