javascript - Adding milliseconds to timer in html -


Is there any way that I can add milliseconds to my timer?

I am currently using this timer but in this count it is only in seconds.

  var number = 99; Var counter = set interval (timer, 1000); // 1000 will run it every 1 second function timer () {count = count-1; If (count & lt; = 0) {clear interval (counter); Return; } Document.getElementById ("Timer"). InnerHTML = count + "seconds"; // clock for spelling}  

thanks

won the timer 'T run with millisecond accuracy - not only the standard JS is below the minimum timeout, timer events queue and all other types of issues in any event (no pun intended) You can not actually see a timer count 1000 times .

Instead use only the window.requestAnimationFrame and show the difference between the time and the timer's reference start time near that function.

  var timer = document.getElementById ('timer'); Var termination = + new date () + 10000; (Work update () {var now = + new date (); var togo = expires - now; if (togo> 0) {timer.innerHTML = togo; window.requestAnimationFrame (update);} else {timer.innerHTML} = 0;}}} ();  
  & lt; div id = "timer" & gt; & Lt; / div & gt;  


Comments

Popular posts from this blog

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

c# - Process.Kill() returns access denied -

c# - Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments -