Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
How do I "clear" my timer using my clear button?

I am new to javascript. I am trying to clear my timer value on clcking the"clear" button.I tried to use the variable"sec" from myTimer function, but it is not working. Any suggestions? Help is appreciated.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

the document.getElementsByTagName gets the button and runs the function when clicked.

let timer;
let increment = 0;

timer = setInterval(() => increment++ , 1000)

//gets the button element and clears timer when clicked
document.getElementsByTagName("button").onclick = function() {
    clearInterval(timer)
}
about 4 years ago · Juan Pablo Isaza Relatório

0

let count = 0
let myTimer;

// set timer
myTimer = setInterval(() => count = count + 1 , 1000)

// clear timer
clearInterval(myTimer)

Show the code of your timer so that I can describe the solution in more detail

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda