2 jQuery .toggle scripts for Login & Register button. How do I slide one up by clicking the other?

StackOverflow https://stackoverflow.com/questions/22729631

  •  23-06-2023
  •  | 
  •  

Domanda

First of all hello everyone. This is my first question here so please forgive me if I mess something up :) and of course I'll try to be as clear as possible. I am a developer and been working with PHP the most but also a little jQuery, but I am still getting the hang of it. Now the question: I have two toggle scripts, one for the login and the other for the register button that slide down their respective form. The scripts work fine but I need to make it so when let's say the login button is active and I want to jump directly to the register, without having to close the one that is open. When I do this now, it just slides over the other form that is already open and it really bothers me for the user to have to close one before opening the other. Here is the basic script:

//login slide script
$(document).ready(function(){
$("#login_btn").click(function(){
$("#login_pop").slideToggle(500);
});
});
//register slide script
$(document).ready(function(){
$("#reg_btn").click(function(){
$("#reg_pop").slideToggle(500);
});
});

I hope I was clear enough and thanks a lot in advance :)

È stato utile?

Soluzione

hope this will work

$(document).ready(function(){
$("#login_btn").click(function(){
$("#reg_pop").hide(500);
$("#login_pop").slideToggle(500);
});
});
//register slide script
$(document).ready(function(){
$("#reg_btn").click(function(){
$("#login_pop").hide(500);
$("#reg_pop").slideToggle(500);
});
});

Altri suggerimenti

You can slide up the login and slide down the register when you click on login ... etc

      //login slide script
        $(document).ready(function(){
          $("#login_btn").click(function(){
            $("#login_pop").slideUp(500);
            $("#reg_pop").slideDown(500);
          });
        });
        //register slide script
        $(document).ready(function(){
          $("#reg_btn").click(function(){
            $("#reg_pop").slideUp(500);
            $("#login_pop").slideDown(500);
          });
        });
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top