Pure JavaScript enables real-time feedback of system time and javascript Real-Time
Use javascript to feedback system time
Use knowledge
JavaScript HTML DOM
The setInterval () method in the html dom does not stop calling the function until clearInterval () is called or the window is closed. The ID value returned by setInterval () can be used as a parameter of the clearInterval () method.
SyntaxsetInterval(code,milliseconds)
Code -- code (can be a function)
Milliseconds -- the time (in milliseconds) that is called here)
Therefore, if we want to let the feedback system time go up, we only need to call the method once every 1000 milliseconds to make the display time move like an alarm clock.
setInterval(function(){myTimer()},1000)
New Date () // obtain the current time. toLocaleTimeString () // converts the time part of the Date object to a string based on the local time. getElementById ("clock") // returns the element with the specified ID. innerHTML = c; // return c to the specified Element
Code Section
<!DOCTYPE html>
Summary
The above section describes how to implement real-time feedback on the system time using pure JavaScript. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!