mardi 30 décembre 2014

toggleClass before if statement

I am wondering why this one is not working. It only works when .removeClass respectively .addClass are added inside the if statement. But this toggle should be executed before the if statement shouldn't it? Is there a way to make this working that way?



$(".submit").click(function() {
$(this).toggleClass("active");
if ($(this).hasClass("active")) {
$(".initialStyle").show();
} else {
$(".initialStyle").hide();
}
});


Many thanks


Aucun commentaire:

Enregistrer un commentaire