JS之清除(停止)定时器clearTimeout

        var btn = document.querySelector('button');
        var timer = setTimeout(function() {
            console.log('爆炸了');

        }, 5000);
        btn.addEventListener('click', function() {
            clearTimeout(timer);
        })

 

posted @ 2022-05-26 02:38  hi123hi159  阅读(601)  评论(0)    收藏  举报