Chrome Extension

Check if element has a class jQuery

$("div").hasClass("trophy");

If you want to check whether a class is assigned to an element or not you can use .hasClass() method of jQuery. In the code snippet, we are checking if the div element has a class 'trophy' or not. It will return boolean true if it has a class 'trophy' and false if it has not class 'trophy'.

Search Index Data (The code snippet can also be found with below search text)

.hasClass() jQuery
Check if div contains a class jQuery
Was this helpful?
0 Comments
Never leave your website again in search of code snippets by installing our chrome extension.
Open Code Manager