JavaScript berhenti setInterval
var myInterval = setInterval(function(){console.log("mmk")}, 2000);
clearInterval(myInterval); //stop that interval
Grepper
var myInterval = setInterval(function(){console.log("mmk")}, 2000);
clearInterval(myInterval); //stop that interval
let autoScroll = window.setInterval(() => {
if (window.scrollY >= document.getElementById('second-part').scrollHeight) {
clearInterval(autoScroll);
}
window.scrollBy(0, 10);
}, 25);
//setinterval on and off
h1 = document.querySelector("h1")
h2 = 0
document.querySelector("#onoff").value = "On"
function funi(){
tr = setInterval(() =>h1.innerHTML = h2 ++, 1000)
}
function onoff(){
currentvalue = document.getElementById('onoff').value;
if(currentvalue == "Off"){
clearInterval(tr)
document.getElementById("onoff").value="On";
}else{
funi()
document.getElementById("onoff").value="Off";
}
}