开发者

window.setInterval - more than expected

Could you guys explain more deeply window.setInterval functionality? I've been asked myself several questions while running that snippet:

var i = 0;
window.setInterval(function(){  
   $('#show').html($('.questions :eq('+i+')'));  
}, 1000);

So, i think that window.setInterval is awesome because it automatically increment i var, displays all divs that nested in .questions before goes new iteration, and stops when last div in .questions is reached.

But the main question if it is possible to change function from outside, for example remove $('.questions :eq('2开发者_高级运维')'), before new iteration?

thanks!


You mean, you want to rewrite the function in between intervals? No, as far as I know, that's not possible. You would have to clearInterval the old function, and add a new one.

The easiest way would be to modify your function so it listens to outside parameters, and behaves according to how they are set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜