show div if class exists jquery code example
Example 1: jquery hasclass
if ($( "#foo" ).hasClass('className')) {
$( "#foo" ).removeClass( 'className');
} else {
$( "#foo" ).addClass( 'className');
}
Example 2: check if a class exists javascript
const element = document.querySelector("#box");
element.classList.contains("active");