Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add a class to an element in javascript

// This is to add a class to any html element after you store it
// in the element variable 

element.classList.add("my-class-name");

// This is to remove a class from the element

element.classlist.remove("my-class-name");


Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #class #element #javascript
ADD COMMENT
Topic
Name
4+9 =