How to check if a DOM element has a class

How to check if the specific DOM element you are referencing has a class?

usecontainsProvided methodclassListObject, namely:


Technically speaking, classList is an object that meets the following conditions:DOMTokenListInterface, which means it implements its methods and properties.

You can view its details belowDOMTokenList MDN page.

Download mine for freeJavaScript beginner's manual

More browser tutorials: