Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
Use the contains method on the classList object:
element.classList.contains('myclass')
Technically, classList is an object that satisfies the DOMTokenList interface, which means it implements its methods and properties.
You can see its details on the DOMTokenList MDN page.