JavaScript Periksa apakah elemen memiliki kelas
if(document.getElementById("myElmentID").classList.contains("hidden")){
// I have the 'hidden' class
}
Grepper
if(document.getElementById("myElmentID").classList.contains("hidden")){
// I have the 'hidden' class
}
const element = document.querySelector("#box");
element.classList.contains("active");
var isMobileVersion = document.getElementsByClassName('snake--mobile');
if (isMobileVersion.length > 0) {
// elements with class "snake--mobile" exist
}
const div = document.querySelector('.info');
div.classList.contains('secondary'); // trueCode language: JavaScript (javascript)