clearInterval is not working
I have a div that is above something I want to showcase, and I have the setInterval
working, but the clearInterval
isn’t firing when it reaches 2 loops.
I have this:
window.setInterval(play_ani_clickthese, 3000);
var fade_count = 0;
function play_ani_clickthese() {
$("#click_these").fadeIn(1000).delay(1000).fadeOut(1000);
fade_count += parseInt('1');
if(fade_count == 2) window.clearInterval(play_ani_clickthese);
}
But when the 'fade_count' reaches 2, it just keeps going.
Any pointers to what 开发者_如何转开发I'm doing wrong?
Use it like this:
var id = window.setInterval(play_ani_clickthese, 3000);
clearInterval(id);
精彩评论