I have a checkbox, which starts a loop of a function called "next". So far that work's correctly. Unckecked box should stop the function loop. That doesn't work. I found in the stackoverflow-forum, that it is necessary to declare a variable of the Interval-ID outside the if-else-statement. No success. Any ideas? This is the code:
$('input[type="checkbox"]').click(function(){
var intervalID = 0;
if($(this).is(":checked")){
var intervalID = setInterval(next, 400);
}
else if($(this).is(":not(:checked)")){
clearInterval(intervalID);
}
}
);
Regards
Aucun commentaire:
Enregistrer un commentaire