• To find out more about the cookies we use, see our Privacy Policy . OK. Classlist - the kinder social network for schools.
  • In this article, we’ll be diving into a fundamental concept of JavaScript that can significantly enhance your front-end development skills: the classList property.
  • const list = element.classList; list.remove("myStyle") ... How many class names the element have: let numb = element.classList.length
  • The classList is a DOMTokenList object that represents the contents of the element’s class attribute. Even though the classList is read-only...
  • Definition and Usage. The classList property returns the class name(s) of an element, as a DOMTokenList object.
  • Using classList is a convenient alternative to accessing an element's list of classes as a space-delimited string via element.className.
  • In essence it's a read-only property that returns a DOMTokenList. The token list contains the classes of the HTML element we call the classList method on.
  • const button = document.querySelector('button'). button.classList.add('active') console.log(button.classList[0]) // 'active'. Скопировать.
  • The classList object, added to all nodes within the DOM, provides developers methods by which to add, remove, and toggle CSS classes on a node. classList also...
  • JavaScript classList - javatpoint - Tutorials List.