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

192
Views
Why doesn't my setInterval function run more than once?

I don't know why my function is not properly called every 100 milliseconds. It is just called once, when the page is loaded/reloaded. I am out of ideas what to try.

var unit = document.getElementsByClassName('unit');
var date = new Date();

function setTime() {
  hour.textContent = date.getHours();
  unit[0].textContent = "h";
  minute.textContent = date.getMinutes();
  unit[1].textContent = "m";

  console.log('boom');
}

setInterval(setTime, 100);
<h1 id="time">
  <span id="hour"></span><!-- 
  --><span class="unit"></span> 
  <span id="minute"></span><!-- 
  --><span class="unit"></span>
</h1>

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!