# How to check if a DOM element has a class

> Learn how to check if a DOM element has a class using the contains method of the classList object, which implements the DOMTokenList interface.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-10-22 | Topics: [Web Platform](https://flaviocopes.com/tags/platform/) | Canonical: https://flaviocopes.com/check-dom-element-class/

Use the `contains` method provided by the `classList` object, which is:

```js
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](https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList).
