I want to make a flipping slidepanel. The JavaScript I came up with is this:
$(document).ready(function(){
$('.menu').click(function(){
$('.sidepanel').animate({"width":"5%"});
$('.rightpanel').animate({"width":"95%"});
if($('.sidepanel').css("width","5%")){
$('.sidepanel').animate({"width":"30%"});
$('.rightpanel').animate({"width":"70%"});
}
else{
$('.sidepanel').animate({"width":"5%"});
$('.rightpanel').animate({"width":"95%"});
}
});
});
What is happening is that when I click on the "menu", it rolls back to width of 5%,, but again goes to 30%, which I want it to go in the second click. I also used another way:
$(document).ready(function(){
$('.menu').click(function(){
$('.sidepanel').animate({"width":"5%"});
$('.rightpanel').animate({"width":"95%"});
}, function(){
$('.sidepanel').animate({"width":"30%"});
$('.rightpanel').animate({"width":"70%"});
});
});
That also not worked. How can I tell jQuery to do something ON THE SECOND CLICK? http://jsfiddle.net/Ju5va/