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

139
Views
Cómo ejecutar una función solo cuando se la llama. JAVASCRIPT

 const START_BTN = document.getElementById("start") const TEXT = document.getElementById("top") let TIMER = document.getElementById("time") START_BTN.addEventListener("click", start) TIMER.innerText = "30" let TIMER_FUNC = setInterval(countdown, 1000); function start(){ START_BTN.style.display = "none" TEXT.style.display = "block" countdown() } function countdown(){ TIMER.innerText-- }
 <div class="game"> <button id="start">Start</button> <div id="top"> <div class="color1">RED</div> <div class="color2">YELLOW</div> </div> <div class="bottom"> <div class="row1"> <button class="blue"></button> <button class="yellow"></button> </div> <div class="row2"> <button class="green"></button> <button class="red"></button> </div> </div> </div> <div class="span"> <span id="score"></span> <span id="time"></span> </div>

Básicamente, quiero que la cuenta regresiva, que es el temporizador, solo comience cuando la función de inicio esté activa. La función de inicio es un botón y cuando se hace clic, quiero que el temporizador baje. Actualmente está cayendo en la carga de la ventana, lo que tiene sentido, pero no es lo que quiero.

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!