Latest web development tutorials

윈도우 사항 clearTimeout () 메소드

윈도우 객체 참조 Window 객체

정의 및 사용

사항 clearTimeout () 메서드는 취소 ()을에서는 setTimeout 시간 제한 방법을 설정합니다.

매개 변수 사항 clearTimeout () 메서드에서는 setTimeout에 의해 반환 된 ID 값이어야합니다 ().

문법

clearTimeout(id_of_settimeout)


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저 사항 clearTimeout를 지원 () 메소드


다음의 예는, 거기에있는 타이머, 입력 필드를 시작하는 버튼을 "시작 카운트!", 당신은 항상 계산되며, 버튼이 타이머 정지 "정지 카운트!"

var c=0;
var t;
var timer_is_on=0;
function timedCount(){
    document.getElementById('txt').value=c;
    c=c+1;
    t=setTimeout(function(){timedCount()},1000);
}
function doTimer(){
    if (!timer_is_on){
        timer_is_on=1;
        timedCount();
    }
}
function stopCount(){
    clearTimeout(t);
    timer_is_on=0;
}

»시도


윈도우 객체 참조 Window 객체