I would like to create an animation when the user clicks on a button. There are two animate functions I want to do on click so I thought I would use the toggle function which swap between the two functions.
Now the problem is if I use the toggle function it is doing the two animate functions without click and also the button disappears.
$('#button').toggle(
function() {
$('#slider').stop().animate({"margin-right": '0'});
},
function() {
$('#slider').stop().animate({"margin-right": '50'});
}
);
How do I do the animate functions alternatively every time when the user clicks a button?
.toggle(fn1, fn2)function is deprecated.