JQuery closes when another switch is open

I have two sliding panels, panel 1 slides down, and panel2 moves to the left. I want to close panel1 when opening panel2. I know that many similar questions have already been answered, but I could not understand how to apply them on my site.

$(document).ready(function(){
  $(".slide-btn1").click(function(){
    $("#panel1").toggle("slow");
    $(this).toggleClass("active");
    return false;
  });
  $(".slide-btn2").click(function(){
    $("#panel2").slideToggle("slow");
    $(this).toggleClass("active");
    return false;
  });
});

Edit: this is what I have done so far http://jsfiddle.net/Pukau/9CFgR/2/

+2
source share
1 answer
$(document).ready(function(){
    $(".slide-btn1").click(function(){
           $("#panel2").slideUp("fast");
            $('.active').removeClass('active');
        $("#panel1").toggle("fast");
        $(this).toggleClass("active");
        return false;
    });
        $(".slide-btn2").click(function(){
             $("#panel1").slideUp("fast");
           $('.active').removeClass('active');
        $("#panel2").slideToggle("slow");
        $(this).toggleClass("active");
        return false;
    });
});​

for a live demo see this link: http://jsfiddle.net/nanoquantumtech/HT9Bx/

+4
source

All Articles