3
I’m trying to alternate 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 initial position.
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 is the Jsfiddle: https://jsfiddle.net/s7q8qt0u/.
How can I get the ball back to where it started?
Grateful!