Using setInterval, you should be able to do something like the following. There's no recursion taking place at all. (Of course, this example is contrived, but should explain the concept.)
Working example: http://jsfiddle.net/TNwAZ/1/
HTML
<div id='myDiv' style="position:relative">div</div>
Javascript
var count = 10;
var duration = 500;
var interval = setInterval(function() {
$('#myDiv').text(count).animate({left: '+=50'},duration);
count--; // Decrement count
if(!count) { clearTimeout(interval) }
}, duration );
EDIT:
Not sure how you are getting the elements to animate, but here's an example of placing references to them in an array, and looping over that.
http://jsfiddle.net/TNwAZ/3/
HTML
<div id='myDiv1' style="position:relative">div 1</div>
<div id='myDiv2' style="position:relative">div 2</div>
<div id='myDiv3' style="position:relative">div 3</div>
Javascript
var divArray = ['myDiv1','myDiv2','myDiv3'];
for(var i in divArray) {
intervalAnimate(divArray[i]);
}
function intervalAnimate(theDiv) {
var count = 10;
var duration = 500;
var interval = setInterval(function() {
$('#' + theDiv).text(count).animate({left: '+=50'},duration);
count--; // Decrement count
if(!count) { clearTimeout(interval) }
}, duration );
}
EDIT:
This version skips the for loop, and just gets a collection of jQuery objects, and passes that in.
http://jsfiddle.net/TNwAZ/5/
HTML
<div id='myDiv1' style="position:relative">div 1</div>
<div id='myDiv2' style="position:relative">div 2</div>
<div id='myDiv3' style="position:relative">div 3</div>
Javascript
var $divs = $('div[id^=myDiv]');
intervalAnimate($divs);
function intervalAnimate(collection) {
var count = 10;
var duration = 500;
var interval = setInterval(function() {
$(collection).text(count).animate({left: '+=50'},duration);
count--; // Decrement count
if(!count) { clearTimeout(interval) }
}, duration );
}