1. Home
  2. Javascript
  3. Class list contains
#javascript#class#list

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.

element.classList.contains('class-name');
copy
Full Javascript cheatsheet
Sitemap Git repository