您现在的位置是:首页 > 电脑技术查询 > web开发

如何定时调用啊 多谢

编辑:chaxungu时间:2022-10-02 23:16:16分类:web开发

怎么定时调用啊 谢谢
var a={
total:8,
x:function(){
this.total--;
document.getElementsByTagName("input")[0].value=this.total;
window.setTimeout(this.x(),1000);
},
m:function(){
window.setInterval(,1000);
}
}

------解决方案--------------------
额,例子:

var a={
total:8,
x:function(){
window.setInterval(function(){a.y(a.total);},2000);//定时调用y方法,并传递参数
},
y:function(index){alert(index);}
}
a.x();