Jeśli klasa istnieje jQuery
if ($(".mydivclass").length){
// Do something if class exists
} else {
// Do something if class does not exist
}
Odd Okapi
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
}
/* Answer to: "jquery check if element has class starting with" */
if(!$(this).is('[class*="answerbox"]')) {
//Finds element with no answerbox class
} else {
//The element has already an answerbox class
}