document.querySelector add class in javascript code example
Example 1: add class queryselector
const element = document.querySelector("#box");
element.classList.add("class-name");
Example 2: add class queryselector
<div id="box"></div>
const element = document.querySelector("#box");
element.classList.add("class-name");
<div id="box"></div>