日期:2014-05-16  浏览次数:20392 次

如何停止setInterval,setTimeout
setInterval( "a() ",1000)启动后如何停止,还有递归的setTimeout,
如function   a(){i++;setTimeout( "a() ",1000);},我想在按一下按钮后让他们停下来,该用什么语句,谢谢!

------解决方案--------------------
function start()
{
var t = setTimeout( "start ",1000);
}
function stop()
{
clearTimeout(t)
}
------解决方案--------------------
var t = setInterval( "start() ",1000);
clearInterval(t)