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实际上清除定时器??因为这个监控按钮只有在处于监控功能时才会被禁用。当单击一个名为. outputremove的元素时,我有另一个clearInterval。请看下面的代码:
//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函数中获取程序?