 <p>The setInterval executes after the function is run, by which point i has incremented to 4. You should create a closure over the element to preserve it</p> <pre><code>setInterval(runnable(elements[i], text, target_date), 1000); // also pass target_date since it is needed function runnable(el, text, target_date) { return function () { // find the amount of "seconds" between now and target var current_date = new Date().getTime(); var seconds_left = (target_date - current_date) / 1000; // do some time calculations days = parseInt(seconds_left / 86400); seconds_left = seconds_left % 86400; hours = parseInt(seconds_left / 3600); seconds_left = seconds_left % 3600; minutes = parseInt(seconds_left / 60); seconds = parseInt(seconds_left % 60); // format countdown string + set tag value el.innerHTML = text + days + "d, " + hours + "h, " + minutes + "m, " + seconds + "s"; } } </code></pre> <p>Demo: <a href="http://jsfiddle.net/87zbG/1/" rel="nofollow">http://jsfiddle.net/87zbG/1/</a></p>