I am a bit new to jQuery, and trying to learn it. I am animating an element after its parent is clicked, but I also want the element to go back to its original state after a set time period. I did try setTimeout but I may be using it wrong, so it didn’t work. Can someone explain how to do this?
var span = $('span');
$('button').click(function(){
span.animate({
left: '200' }, 500, 'linear', function() {
});
});
You could do that like this. You save the original value for left and use the
delay()method to chain multiple animations with a time delay between them:Working demonstration here: http://jsfiddle.net/jfriend00/zB5NL/