jquery setTimeout inside each
问题 i have some code similar to this, that moves inside some images... it works but it doesn't seem to respect timer var i = 1; var indexArray = array(1,2,3); var timerx = new Array(); $( indexArray ).each(function( indexArraykey ) { function internalCallback ( i, indexArraykey ) { val = indexArray[indexArraykey]; console.log("test " + i + val); }); timerx[i] = setTimeout( internalCallback( i, indexArraykey ), i * 500000 ); i++; }); 回答1: A few points : i has the value of end of loop by the time