Home > Web Front-end > JS Tutorial > Add parameters to settimeout method in js_javascript skills

Add parameters to settimeout method in js_javascript skills

WBOY
Release: 2016-05-16 16:57:57
Original
837 people have browsed it

The use of settimeout method and parameters in js.
For simple use, see w3school
There is no parameter call in it,
Example:

Copy code The code is as follows:





My current problem is Between them, only the last one is sent back, think about it
Copy the code The code is as follows:

/* for (var i=0;iAddGuiJi(points[i],value);
//var t=setTimeout(function(){ AddGuiJi(points [i],value);},2000*i)
} */

The reason for the above error is that when time is triggered for execution, i=4, so although there are multiple But always the last
solution
Copy code The code is as follows:

var timerr ;
function xunhuanlian(points,value){
if(replayiAddGuiJi(points[replayi],value);
replayi ;
timerr=setTimeout(function (){ xunhuanlian(points,value);},1000);
}
else{
replayi =0;
clearTimeout(timerr);
}
/* for ( var i=0;iAddGuiJi(points[i],value);
//var t=setTimeout(function(){ AddGuiJi(points[i],value) ;},2000*i)
} */
}
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