JavaScript Compruebe si el elemento tiene clase
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
}
// given an element: <div id="myID" class="wrapper active">
//JQuery answer
if ( $("#myID").hasClass("active") ){
//true: myID has class active
} else {
//false: myID does not have class active
}
if ($(".mydivclass").length){
// Do something if class exists
} else {
// Do something if class does not exist
}
$("#EL_ID").hasClass("CLASS_NAME");
if ($(".mydivclass")[0]){
// Do something if class exists
} else {
// Do something if class does not exist
}
if ($("#about").hasClass("opened")) {
$("#about").animate({right: "-700px"}, 2000);
}