1
私は以下のようなコードを用意しています。停止ボタンをクリックすると、bExitフラグが1に設定されます。コンソールでは、単語の消去が2秒間隔で繰り返されます。タイムアウトをクリアして、単語のクリアが繰り返されないようにするにはどうすればよいですか?grepのcleartimeout?
//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);
});
違いがありません – Rob
すべてのタイマーを保存するために、1つの変数 'timer0'を使用している可能性がありますか?あなたが 'var timer0 = setTimeout(function(){'? –
がgrep/loopのための1つのタイマーにすぎないと言ったとしたら? – Rob