element.classList.add("div-class");
var element = document.querySelector('.box');
// using add method
// adding single class
element.classList.add('color');
// adding multiple class
element.classList.add('border', 'shadow');
element.classList.add('class');
element.classList.remove('class');
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.
// 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");
const root = document.getElementsByTagName('html')[0]
root.classList.add('hide-scrollbar')
element.classList.add("my-class");
const exampleElement = document.createElement('div');
exampleElement.classList.add("exampleClass");
const container = document.getElementById('container1');
container.appendChild(exampleElement);