Here, “className” is the name of the CSS class that will be searched in the particular element.
While the syntax of the hasClass() method in jQuery is:
Create a “div” element, assign a CSS class “flex-item1” to style the div, and add an image of the logo of the website using the “src” attribute of the <img> tag inside the div element:
Create a CSS class “flex-item1” to style the div:
Call the “contains()” method of the classList object by passing the class “flex-item1” to determine whether the specified div element contains this class:
Finally, print the result on the console using the “console.log()” method:
It can be observed that the contains() method returned “true” which means the specified element contains the given CSS class: