bigloop=setInterval(function () {
var checked = $('#status_table tr [id^="monitor_"]:checked');
if (checked.index()===-1 ||checked.length===0 || ){
bigloop=clearInterval(bigloop);
$('#monitor').button('enable');
}else{
(function loop(i) {
//monitor element at index i
monitoring($(checked[i]).parents('tr'));
//delay of 3 seconds
setTimeout(function () {
//when incremented i is less than the number of rows, call loop for next index
if (++i < checked.length) loop(i);
}, 3000);
}(0)); //start with 0
}
}, index*3000); //loop period
我上面有代码,有时可以工作,有时不能。我想知道clearInterval是否实际上清除了计时器?因为有一个此monitor按钮只有在启用时才会被禁用monitoring。单击clearInterval名为的元素时,我还有另一个.outputRemove。请参见下面的代码:
//remove row entry in the table
$('#status_table').on('click', '.outputRemove', function () {
deleted= true;
bigloop= window.clearInterval(bigloop);
var thistr=$(this).closest('tr');
thistr.remove();
$('#monitor').button('enable');
$('#status_table tbody tr').find('td:first').text(function(index){
return ++index;
});
});
但是启用了一段时间后才再次禁用它。会clearInterval从setInterval功能中取出程序吗?
错别字。我有一个
—
yvonnezoe
clearloop(loopname)包含的函数,clearInterval但是为了简化它,我直接在上面的代码中对其进行了更改。
loopname在第二个片段中?那是什么?