开发者

Toggle TWO Drop Down Panels

开发者 https://www.devze.com 2023-01-17 18:23 出处:网络
I am using two panels at the top of my web page that drop down:\"Fast Quote\" and \"Client Login\".Can someone show me how to alter my code so that ONLY ONE panel is open at one time?Example:If \"Clie

I am using two panels at the top of my web page that drop down: "Fast Quote" and "Client Login". Can someone show me how to alter my code so that ONLY ONE panel is open at one time? Example: If "Client Login" is open and the user clicks on "Fast Quote", the "Client Login" should close and the "Fast Quote" drops down.

Here is my website: http://www.ubspack.com

CODE:

$(document).ready(function(){
 $(".btn-slide").click(function(){
  $("#panel_quote").slideToggle("slow");
  $(this).toggleClass("closeQ"); return false;
 });
 });



  $(document).ready(function(){
 $(".btn-slide2").click(function(){
  $("#panel_login").slideToggle("slow");开发者_Python百科
  $(this).toggleClass("closeL"); return false;
 });
});


you would just close the other panel in your click handlers.

$(document).ready(function(){
  $(".btn-slide").click(function(){
    $("#panel_quote").slideToggle("slow");
    $(this).toggleClass("closeQ"); 
    $("#panel_login").slideUp();
    return false;
  });

  $(".btn-slide2").click(function(){
    $("#panel_login").slideToggle("slow");
    $(this).toggleClass("closeL"); 
    $("#panel_quote").slideUp();
    return false;
  });
});


Try something like:

    $(document).ready(function(){
     $(".btn-slide").click(function(){
          return Toggle()
     });

     $(".btn-slide2").click(function(){
          return Toggle()
     });

    });

function Toggle() {
     $(".btn-slide1").toggleClass("closeQ");
     $(".btn-slide2").toggleClass("closeL");
}

Calling Toggle() will toggle both classes at the same time - then it's simply a case of making sure one has the class applied to start with...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号