check if a class exists javascript
snippet in javascript

check if a class exists javascript

user6226

const element = document.querySelector("#box");

element.classList.contains("active");

check if a class exists javascript

user5869

<div id="box" class="active"></div>