What i’m trying to do is avoid having both #login and #signUp displayed at the same time, so is there a check i could do that if the other is currently being shown, first slide it up and then carry on with the slidedown of the clicked trigger?
Does that make sense?
$("#loginBtn").click(function(){
$("#login").slideToggle();
return false;
});
$("#signUpBtn").click(function(){
$("#signUp").slideToggle();
return false;
});
You can check if the other element is visible before you call slideToggle by using
is(":visible"), you invoke theismethod on a selector and specify the:visibleselector in the is method:It will return either
trueorfalse. To implement this in your current code you would do so like this:So this will check if #signUp is visible first and if it is, it will hide it. After the #signUp has been hidden, the #login will show. If #signUp is not visible, #login will just show. The same for #logIn but the other way around.