The jQuery hasClass()
is a built-in method used to check whether the selected elements, with a specified class name, exist or not. hasclass()
returns a boolean value. If a specified class is present in any of the selected elements, a true
value is returned; otherwise, the method returns a false
value.
In the code above, the hasClass()
method is used to check whether temp1 and temp2 have used red class or not. Since temp1 has used red class, it returns true, but temp2 used bold class, so it returns false.
Free Resources