日期:2014-05-18 浏览次数:20964 次
var count = 0;
var toCount = 10;//指定次数
function ourmove(){
if (count < toCount) {
count++;
//ourmove函数要执行的代码
} else {
anotherFunction();
}
}
function anotherFunction() {...}
setInterval(ourmove,1);
------解决方案--------------------
定义一个int变量,js函数每执行一次加一,然后用变量作判断不就行了吗。
------解决方案--------------------
var count = 0;
var toCount = 10;//指定次数
function ourmove(){
if (count < toCount) {
count++;
//ourmove函数要执行的代码
} else {
clearInterval(itid);
anotherFunction();
}
}
function anotherFunction() {...}
var itid = setInterval(ourmove,1);