Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JS DOM how to add a class name to any HTML element

var element = document.querySelector('.box');
// using add method
// adding single class
element.classList.add('color');

// adding multiple class
element.classList.add('border', 'shadow');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #JS #DOM #add #class #HTML #element
ADD COMMENT
Topic
Name
7+3 =