Can you please take a look at this snippet and let me know if there is a way to check weather the setInterval() is really killed or still running in background processing?
Technically what I need to do is killing the JS setinerval whenever the .map is not in the page. my understanding is the setInterval() still running ever 2 second just is not writing on the console because of if statement
setInterval(
function() {
if ($(".map")[0]) {
console.log("Map is in the Page");
} else {
//Stop Inreval
}
}, 2000);
setTimeout(function(){ $(".box").empty();
}, 9000);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="box">
<div class="map">Map in Here</div>
</div>