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

201
Views
Count up timer doesn't work (setInterval part)

I noticed that the setInterval part makes the code not work. No error is being shown. It works when I manually press the button one at a time.

const stopWatch = document.getElementById("time");
let totalSecs = 0;
const start = document.getElementById("start");


let timeCount = setInterval(seconds, 1000);
let seconds = () => {
  start.innerHTML = "Clicked!";
  ++totalSecs;
  let hr = Math.floor(totalSecs / 3600);
  let min = Math.floor(totalSecs / 60);
  let sec = totalSecs - hr * 3600 - min * 60;
  stopWatch.innerHTML = `${hr} : ${min} : ${sec}`;
}

document.addEventListener("click", seconds);
<div id="time">
</div>
<button id="start">Start</button>

about 4 years ago · Santiago Gelvez
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!