How can I provide a specific id setInterval()and then call clearInterval()by id.
$('.notify').each(function () {
var chkr = $(this).find('span').text();
if (chkr == 'Offline') {
if (typeof(clearC) !== 'undefined') {
clearInterval(clearC);
}
clearC = setInterval(function () {
soundOn();
}, 500);
}
else {
if (typeof(clearC) !== 'undefined') {
clearInterval(clearC);
}
}
});
The problem is when the statement is executed if, then the sound continues. But for the next line, type in the statement else(because "Internet") and clear the interval, although it should not be.
So I'm worried to clear clearIntervalfor a specific line until the text "Online" appears.
source
share