Answers for "how to check if a class exists on page in javascript"

5

check if a class exists javascript

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

element.classList.contains("active");
Posted by: Guest on August-08-2020
0

js class exists

var isMobileVersion = document.getElementsByClassName('snake--mobile');
if (isMobileVersion.length > 0) {
    // elements with class "snake--mobile" exist
}
Posted by: Guest on April-06-2022

Code answers related to "how to check if a class exists on page in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language