4
I have the variable X
X = setInterval(function() { ...
and after a while I stopped in that setInterval with the function clearInterval(X)
How do I call this variable to continue the loop after I have "deleted it"?
4
I have the variable X
X = setInterval(function() { ...
and after a while I stopped in that setInterval with the function clearInterval(X)
How do I call this variable to continue the loop after I have "deleted it"?
6
You can’t stop and start one over setInterval
. What you can do is:
Sets the function outside the setInterval
and then starts/starts again:
function beeper(){
// fazer algo
}
var x = setInterval(beeper, 1000);
// para parar:
clearInterval(x);
// para recomeçar:
x = setInterval(beeper, 1000);
var semaforoVermelho = false;
function beeper(){
if (semaforoVermelho) return;
// fazer algo
}
setInterval(beeper, 1000);
// para pausar:
semaforoVermelho = true;
// para recomeçar:
semaforoVermelho = false;
Browser other questions tagged javascript jquery
You are not signed in. Login or sign up in order to post.