I'm trying to make an animation that behaves like a toggle. What I want is that with the click event on #admin > p
, it deflects to the left while the #admin > form, #btn
slideUp returns to the original position (css) when #admin > form, #btn
does slide down again.
Here is my code:
$('#admin > p').click(function(){
$('#admin > form, #btn').stop(true).slideToggle();
})
$('#admin > p').toggle(function() {
$(this).animate({'left':'20px'});
}, function() {
$(this).animate({'right':'20px'});
});