나는 CSS 배경 그림을 간격으로 1 초마다 바꾼 기능을 썼다. 그리고 그 모든 것이 잘 작동한다. 문제는 배경 화면과 간격 설정을 바꾸는 기능을 멈추고 싶다는 것이다. 계속 덮어 씁니다.js setInterval을 멈추는 방법
내 코드 :
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]);
나는 사용하여 시도 : 위해 clearInterval을();
이 괴물을 어떻게 중지합니까?
가 SO에 이런 질문을하기 전에, 당신이 사용하고있는 기능에 대한 문서를 검색하십시오. ['setInterval'문서] (https://developer.mozilla.org/en/docs/Web/API/window.setInterval)에는 [필요한 기능] (https://developer.mozilla.org) 링크가 있습니다. /en-US/docs/Web/API/window.clearInterval). – Cerbrus
http://stackoverflow.com/questions/109086/stop-setinterval-call-in-javascript?rq=1 –