我想在 setInterval 中运行一个函数,并在每次 setInterval 运行时更改该函数的变量,这是我目前所拥有的:
$pages = new Array();
$pages.push("home.html","drp.html","drs.html","dffi.html","dci.html","dcp.html","drma.html","construction.html","orgChart.html");
$a = 0;
setInterval(function(){
$getPage = $pages[$a]
$(this).getPageToLeft();
$a++
alert($a);
},5000);
问题是 $a 每次 setInterval 运行时都设置回 0,我需要它在每次 setInterval 运行时增加。