我试图停止/清除间隔,但我收到错误。下面如何停止/清除间隔
代码:
function play(){
function sequencePlayMode() {
var arg1;//some arguments
var arg2;//some arguments
changeBG(arg1,arg2);//here is function that changes the background
}
var time = 5000;
var timer = setInterval(sequencePlayMode, time);//this starts the interval and animation
}
function stop(){
var stopPlay = clearInterval(sequencePlayMode);//here i'm getting error "sequencePlayMode is not defined"
}
$("#startAnimation").click(function(){
play();
});
$("#stopAnimation").click(function(){
stop();
});
有人可以帮助我吗?
clearInterval(timer);试试这个 – laaposto
可能的重复[停止JavaScript中的setInterval调用](http://stackoverflow.com/questions/109086/stop-setinterval-call-in-javascript) – plalx