我有以下代码,这些代码为了示例目的而缩减。当我单击我的停止按钮时,bExit标志设置为1.在控制台中,以2秒的间隔重复单词清除。如何清除超时,以便清除单词不会重复?
//stop playback
$('.stop').live('click', function () {
bExit = 1
console.log("stopping...");
clearTimeout(timer0);
});
var timer0;
var obj = $.grep(thedata, function (e, index) {
timer0 = setTimeout(function () {
if (bExit == 1) {
console.log("clearing...");
//$(".nodeCount,.statInfo,.theborder").hide();
clearTimeout(timer0);
return
}
}, 2000 * index);
});