Home > Web Front-end > JS Tutorial > HTML js realizes dynamic display of local time_javascript skills

HTML js realizes dynamic display of local time_javascript skills

WBOY
Release: 2016-05-16 17:21:54
Original
1155 people have browsed it
Copy code The code is as follows:

< ;html>


setInterval("test()",1000);
function test ()
{
var a= new Date();
< ;/span>document.getElementById("time").innerHTML= a;
}







I don’t know what setInterval means, so Baidu Down.

Found this to mean:

The setInterval() method can call a function or calculate an expression according to the specified period (in milliseconds).
The setInterval() method will keep calling the function until clearInterval() is called or the window is closed. The ID value returned by setInterval() can be used as an argument to the clearInterval() method.

The method provided by w3school is:
Copy the code The code is as follows:

setInterval(code, millisec[,"lang"])

code is the function to be called, millisec is the period, and the time is calculated in milliseconds
Copy code The code is as follows:










Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template