list= ["x1", "x2", "x3"]; var i=-1; a= function(){ if (i == list.length-1) return; ++i; $("#"+list[i]).animate({left: "+=50"}, 1000, a); }; a();