1
I’m trying to reverse a simple animation when I press a button again. The first click animates a div removing its left margin, but when I press again I wanted to put the margin back in its normal value which is the 250px. For this purpose I decided to use jQuery’s toggle. The edge animation runs normally but the problem is that the div also disappears and reappears every time I press the button, which I suppose is the normal toggle behavior. My code is this::
$("#sidebar-toggle").click(function(){
$("#content").toggle(function(){
$(this).animate({marginLeft:0},200);
},function(){
$(this).animate({marginLeft:'250px'},200);
});
})
Perfect :) thank you very much!
– SergioNeves