|
Close one jquery panel when opening other one
Hi I have 2 panels on my page ... if I click on one panel if the other is opened it close it before opening other one and vice versa..byt unfortunately the active classes are not cahnging accordingly.
This is my code:
jQuery(function( $ ){
// Get a reference to the container.
var container = $( "#panel" );
var containermap = $( "#map" );
// Bind the link to toggle the slide.
$( ".btn-slide" ).click(
function( event ){
// Prevent the default event.
event.preventDefault();
// Toggle the slide based on its current
// visibility.
if (container.is( ":visible" )){
// Hide - slide up.
container.slideUp( 500 );
$(this).removeClass("active");
} else {
// Show - slide down.
container.slideDown( 500 );
$(this).addClass("active");
}
if (containermap.is( ":visible" )) {
//alert('test');
containermap.slideUp( 500 );
$(this).removeClass("active-map");
container.slideDown( 500 );
$(this).addClass("active");
}
}
);
$( ".btn-map" ).click(
function( event ){
event.preventDefault();
if (containermap.is( ":visible" )){
containermap.slideUp( 500 );
$(this).removeClass("active-map");
} else {
containermap.slideDown( 500 );
$(this).addClass("active-map");
}
if (container.is( ":visible" )) {
container.slideUp( 500 );
$(this).removeClass("active-map");
containermap.slideDown( 500 );
$(this).addClass("active-map");
}
}
);
});
Please have a look...I want when the panel is closing it reove the active classes...but it doesn't seem to work.Any help please.Urgent
Thnak you
//Sam
|