Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Crie um cronometro utilizando o setInterval. Deve ser possรญvel
- // iniciar, pausar e resetar
- // selecionando os botรตes do cronomentro
- const iniciar = document.querySelector(".iniciar");
- const pausar = document.querySelector(".pausar");
- const resetar = document.querySelector(".resetar");
- // Span onde mostra o cronometro rolando
- const tempo = document.querySelector(".tempo");
- iniciar.addEventListener("click", iniciarTempo);
- pausar.addEventListener("click", pausarTempo);
- resetar.addEventListener("click ", resetarTempo);
- let i = 0;
- let timer;
- function iniciarTempo() {
- timer = setInterval(() => {
- tempo.innerText = i++;
- }, 1000);
- iniciar.setAttribute("disabled", "");
- }
- function pausarTempo() {
- clearInterval(timer);
- iniciar.removeAttribute("disabled");
- }
- function resetarTempo() {
- tempo.innerText = 0;
- i = 0;
- console.log("resetou");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement