I wrote a function that change css background image every 1 second base on interval, and its all working fine, the problem is that now i want to stop the function that switches the background image and the interval setup keep overwriting me.
my code:
var backgrounds = new Array(
'url(/srv/admin/img/announcement/envelope_blue.png)'
, 'url(/srv/admin/img/announcement/envelope_red.png)'
);
var current = 0;
function nextBackground() {
current++;
current = current % backgrounds.length;
jQuery("#open_msg_tlbr_img").css('background-image', backgrounds[current]);
jQuery("#open_msg_tlbr_img").css('width','35px');
jQuery("#open_msg_tlbr_img").css('height','35px');
}
setInterval(nextBackground, 1000);
jQuery("#open_msg_tlbr_img").css('background-image', backgrounds[0]);
I tried using : clearInterval();
how do i stop this monster?