jquery
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'.
Was this helpful?
Similar Posts