function run(){ $('#back').animate({left: '+=500'}, 5000, function() { $('#back').animate({left: '-=500'}, 5000, run()); // * }); }; run();