# contains method of the classList object

The `contains` method of the `classList` object checks for the presence of an element's CSS class.

## Syntax

`element.classList.contains(class);`

## Example

We check if an element has the class `ggg`:

`<p id="elem" class="www ggg zzz"></p>` `let elem = document.querySelector('#elem'); let contains = elem.classList.contains('ggg'); console.log(contains);`

The code execution result:

`true`

## See also

- the `classList.add` method
  that adds a given class
- the `classList.remove` method
  that removes a given class
- the `classList.toggle` method
  which toggles a given class

← →
↑
en ru