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

Add parameters to settimeout method in js_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 16:57:57883browse

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)
} */
}
Statement:
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