Kann clearInterval () in setInterval () aufgerufen werden?
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
Ich habe den obigen Code und manchmal funktioniert es, manchmal nicht. ich frage michob das clearInterval tatsächlich den timer löscht ??? weil es das gibtmonitor
Schaltfläche, die nur deaktiviert wird, wenn sie aktiviert istmonitoring
Funktion. Ich habe ein anderesclearInterval
wenn ein Element aufgerufen wird.outputRemove
angeklickt wird. Siehe den Code unten:
//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;
});
});
Es wurde jedoch für eine Weile aktiviert, bevor es wieder deaktiviert wird.WilleclearInterval
Holen Sie sich das Programm aus dersetInterval
Funktion?