Multi slideout divs
Multi slideout divs
Hi,
By searching the web I've found a way to have multi divs slideout from the left but I can't figure out how to toggle them i.e. when one div is clicked the previous opened divs closes. This my jQuery so far, would appreciate someone's help thank you.
jQuery(function($) {
// jQuery 1.9 > Toggle Event dep 1.8
$('#slideClick').click(function() {
var it = $(this).data('it') || 1;
switch ( it ) {
case 1 :
$(this).parent().animate({left:'0px'}, {queue:false, duration: 500});
break;
case 2 :
$(this).parent().animate({left:'-290px'}, {queue: false, duration: 500});
break;
}
it++;
if(it > 2) it = 1;
$(this).data('it', it);
})
$('#slideClick-2').click(function() {
var it = $(this).data('it') || 1;
switch ( it ) {
case 1 :
$(this).parent().animate({left:'0px'}, {queue:false, duration: 500});
break;
case 2 :
$(this).parent().animate({left:'-290px'}, {queue: false, duration: 500});
break;
}
it++;
if(it > 2) it = 1;
$(this).data('it', it);
})
// jQUery < 1.9
/*$('#slideClick').toggle(function() {
$(this).parent().animate({left:'0px'}, {queue:false, duration: 500});
}, function() {
$(this).parent().animate({left:'-290px'}, {queue:false, duration: 500});
}); */
});