Html + js enables dynamic display of local time

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Span style = "font-size: 18px"> <Span style = "white-space: pre"> </span> <body>
<Span style = "white-space: pre"> </span> <script language = javascript>
<Span style = "white-space: pre"> </span> setInterval ("test ()", 1000 );
Function test ()
{
<Span style = "white-space: pre"> </span> var a = new Date ();
<Span style = "white-space: pre"> </span> document. getElementById ("time"). innerHTML =;
}
<Span style = "white-space: pre"> </span> </script>
<Span style = "white-space: pre"> </span>

<Span style = "white-space: pre"> </span> </Body>
</Html>
</Span>

I don't know what setInterval means, So Baidu goes down.

It means:

The setInterval () method can call functions or computation expressions according to the specified period (in milliseconds.
The setInterval () method 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.

W3school provides the following methods:
Copy codeThe Code is as follows:
SetInterval (code, millisec [, "lang"])

Code is the function to be called. millisec is the cycle and the time is calculated in milliseconds.
Copy codeThe Code is as follows:
<Html>
<Body>

<Input type = "text" id = "clock" size = "35"/>
<Script language = javascript>
Var int = self. setInterval ("clock ()", 50)
Function clock ()
{
Var t = new Date ()
Document. getElementById ("clock"). value = t
}
</Script>
</Form>
<Button onclick = "int = window. clearInterval (int)">
Stop interval </button>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.