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>