if($('body').hassClass(!excptThisPage)) { // do thiss } else if ($('body').hasClass(excptThisPage)) { // do this } else { // do nothing }