// if class exist the expresion will return true and the code from if statement will execute if ($(".mydivclass")){ // Do something if class exists } else { // Do something if class does not exist }