I want to add some animations to my website using jQuery, but I lack the skills to create them from scratch. I have managed to copy some code snippets, but I am facing an issue with one of my animations. When I click a button, the block animates, but I want it to return to its original position after the animation ends. This way, multiple clicks on the button won't take the block too far away. Here is the code I am using:
HTML
<div id="button">Click here</div>
<div id="square"></div>
CSS
#square { width:100px; height:100px; position:relative;}
JavaScript
$( "#button" ).click(function() {
$( "#square" ).animate({
left: "-=60px",
}, 400);
});
Is there a way to make the square return to its initial position after the animation is complete?