“SetInterval encendido y apagado” Código de respuesta

JavaScript Stop SetInterval

var myInterval = setInterval(function(){console.log("mmk")}, 2000);

clearInterval(myInterval); //stop that interval
Grepper

JavaScript Stop SetInterval

let autoScroll = window.setInterval(() => {
  if (window.scrollY >= document.getElementById('second-part').scrollHeight) {

    clearInterval(autoScroll);
  }

  window.scrollBy(0, 10);
}, 25);
Lioruby

SetInterval encendido y apagado

//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";
  }
}
Evil Eland

Respuestas similares a “SetInterval encendido y apagado”

Preguntas similares a “SetInterval encendido y apagado”

Más respuestas relacionadas con “SetInterval encendido y apagado” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código