What I want is this (news ticker type functionality):
As Greg mentioned the problem is with the closure only evaluating once. Nobody posted a solution for this so here is one. This uses adding a function that generates the callback function each time:
Add:
function getShowTextCallback(text) {
return function(){showText(text)}
}
Then use it in loop like this:
for(var x=0; x < li.length; x++){
var li_text = li[x].childNodes[0].nodeValue;
setTimeout(getShowTextCallback(li_text), 1000);
}