I am trying to toggle the animation of a div
using .toggle()
, but this div
, which is the first gray ball, simply disappears after I click the button (orange ball), instead of returning to its position initial.
function main() {
$('.mainBtn').click(function(){
console.log("bolaxa");
$('#btn1').toggle(
function () {
$(this).animate({left:'250px'}, 300);
},
function () {
$(this).animate({right:'250px'}, 300);
}
);
});
}
$(document).ready(main);
Here's the JSFiddle: link . How can I get the ball back to its starting place?
Thank you!