New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Use clearInterval() method:
var f = null;
function t(){
z=1
document.getElementById("v").disabled = true;
if (f===null) f=setInterval(q, 10);
}
function stop(){
document.getElementById("v").disabled = false;
z=0;
if (f!==null) clearInterval(f);
f = null;
}
[edited to correct a little mistake]