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

127
Views
"ontimeupdate" not working in my JavaScript

I am trying to output the time of the video duration as it progresses using the ontimeupdate event handler on the video but it doesn’t work.

I added a console.log in the code as well to test but it doesn’t work.

This is the HTML code:

<video id="poster" class="w-100 h-100 image-align" autoplay muted loop src="<?= word("URL_VIDEO") ?>" loading="lazy"></video>

<span id="poster-duration" class="ms-4 text-white">00:00</span>

Here is my script:

window.addEventListener('load', function() {
  var poster = document.getElementById('poster');

  poster.ontimeupdate = function(){
    document.getElementById('poster-duration').innerText = addO(Math.floor(poster.duration/60)) + ':' + addO(Math.round(poster.duration%60));
    console.log("hello")
  };

  function addO(n){
    if( n.toString().length < 2 ){
      return '0'+n;
    }

    return n;
  }

  // ...
});
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!