Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript add class to element

const element = document.querySelector('CSS_SELECTOR')

element.classList.add('class-1') // add class-1
element.classList.remove('class-1') // remove class-1
element.classList.toggle('class-1') // add class-1 if the element does not contains the class, remove if not.
 
PREVIOUS NEXT
Tagged: #javascript #add #class #element
ADD COMMENT
Topic
Name
9+6 =