function count(){
//user input stored in the last index of the array each cycle
array[lastindex]=userinput;
setInterval(count,5000);
}
像我上面的示例代码,我通过存储用户输入来填充数组。但是,我想再添加一个这种情况,即如果用户不在5秒内输入任何内容,我仍然能够存储一个“标记”,表明这一点。换句话说,如何在下一个周期之前自动检测到这一点?谢谢你如何跟踪每个setInterval周期?
没有完全得到你的问题,但clearInterval()可能有帮助 – jimy 2011-03-15 12:33:44
50000不是5秒。 – 2011-03-15 12:34:45
你能解释一下你解决这个问题吗? – Slartibartfast 2011-03-15 13:01:04