Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

jquery
hasclass()

What is the jQuery hasClass() method?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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.

svg viewer

Code explanation

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.

RELATED TAGS

jquery
hasclass()
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring