How to check if element has class in JavaScript

DOM
By Jad Joubran · 
Last updated Mar 02, 2020
<div id="box" class="active"></div>
const element = document.querySelector("#box");

element.classList.contains("active");
true
JavaScript has class on Learn JavaScript Blog