This is my code for window.setInterval
and window.clearInterval
.
window.setInterval
are work good, but when i tried to call window.clearInterval
it's will show error intervalId is not defined
How can i do ?
.....................................................
<div onclick="start_setinterval('1')">START</div>
<div onclick="start_setinterval('0')">STOP</div>
<script>
function start_setinterval(status) {
var xxx = setInterval(function() {
if (status == 1) {
do_start_setinterval();
} else {
clearInterval(xxx);
}
}, 5000);
}
function do_start_setinterval() {
alert("test");
}
</script>