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.
精彩评论