1. Home
  2. Javascript
  3. Class list contains

Check if the given class exists in the element's class list. Returns True if the class exists. Use only the class name without the dot notation. 'contains' method belongs to the 'classList' property.

#javascript#class#list
element.classList.contains('class-name');
copy
Full Javascript cheatsheet