Example of using the settimeout method and parameters in js
This article describes how to use the settimeout method and parameters in js. For more information, see
W3school for simple use
There is no parameter call,
Example:
The Code is as follows:
<Script type = "text/javascript">
Function timedMsg ()
{
Var a = "dd ";
Var t = setTimeout (function () {cao (a);}, 3000)
}
Function cao ()
{
Alert ();
}
</Script>
</Head>
<Input type = "button" value = "display the scheduled warning box" onClick = "timedMsg ()">
The problem I have now is that only the last one is passed back. Think about it.
I still don't quite understand.
The Code is as follows:
/* For (var I = 0; I <points. length; I ++ ){
AddGuiJi (points [I], value );
// Var t = setTimeout (function () {AddGuiJi (points [I], value) ;}, 2000 * I)
}*/
The cause of the above error is that I = 4 when the time is triggered, so although there are multiple, it is always the last one.
Solution
The Code is as follows:
Var timerr;
Function xunhuanlian (points, value ){
If (replayi <points. length ){
AddGuiJi (points [replayi], value );
Replayi ++;
Timerr = setTimeout (function () {xunhuanlian (points, value) ;}, 1000 );
}
Else {
Replayi = 0;
ClearTimeout (timerr );
}
/* For (var I = 0; I <points. length; I ++ ){
AddGuiJi (points [I], value );
// Var t = setTimeout (function () {AddGuiJi (points [I], value) ;}, 2000 * I)
}*/
}