Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
¿Cómo puedo manipular el DOM después de un tiempo determinado?

¿Cómo puedo manipular el DOM después de algún retraso? Quiero que el fondo cambie a verde y que la puntuación se actualice una vez que el jugador acierte. Luego, después de algunos segundos, quiero que el fondo vuelva al estado inicial y al número oculto que configuré para que sea un número generado aleatoriamente para cambiar. Todo salió bien usando setInterval pero resulta que el número oculto continúa regenerándose dentro del tiempo dado.

 //This is the function for the timer function correctDefault() { setInterval(() => { document.querySelector('body').style.backgroundColor= '#222' document.querySelector('.number').style.width= '15rem' document.querySelector('.number').textContent = '?' // secretNumber = Math.trunc(Math.random() * 20) + 1; document.querySelector('.number').textContent = secretNumber }, 3000); } //And this is the condition else if (guess === secretNumber) { if (score !== 50) { document.querySelector('body').style.backgroundColor= '#60b347' displayMessage('🎉 Correct Number!') score++ document.querySelector('.number').style.width= '17rem' document.querySelector('.number').textContent = secretNumber document.querySelector('.score').textContent = score; correctDefault() } else{ displayMessage('👏 You Won the Game') document.querySelector('.highscore').textContent = score; document.querySelector('body').style.backgroundColor= 'rgb(180, 245, 0' document.querySelector('.number').textContent = guess } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!