The hasClass() method checks if any of the selected elements have a specified class name. If ANY of the selected elements has the specified class name, this method will return "true". To find the class of clicked element, we use this. className property. The className property is used to set or return the value of an element's class attribute. Using this property, the user can change the class of an element to the desired class To check if the element contains a specific class name, we can use the contains method of the classList object. It returns a Boolean value. If the element contains the class name it returns true otherwise it returns false The HTML class attribute is used to specify a class for an HTML element. Multiple HTML elements can share the same class.
https://core-ball.org/
|