I use the following code to hide and show a div every 1 sec
$(document).ready(function(e) {
var acc = setInterval(function(){
$("#element").fadeOut(function(){
setTimeout(function(){
$("#element").fadeIn()
}, 1000)
})
}, 200)
})
$(window).load(function(){
setTimeout(function(){
clearInterval(acc);
}, 10000)
})
The clearInterval() is not working as it should and I get the following error on Google Chrome:
Uncaught ReferenceError: acc is not defined
There is a scope issue in your code, you have defined the
accvariable locally in the context of the document ready handler and it’s not defined in the context ofloadhandler.