Javascript, countdown timer and display text

前端 未结 3 1493
耶瑟儿~
耶瑟儿~ 2021-02-09 03:16

I am making a countdown timer with JavaScript.

Here is my script.

var seconds_left = 10;
var interval = setInterval(function() {
    document.getElementB         


        
3条回答
  •  别跟我提以往
    2021-02-09 03:57

    var seconds_left = 10;
    var interval = setInterval(function() {
        document.getElementById('timer_div').innerHTML = --seconds_left;
    
        if (seconds_left <= 0)
        {
            document.getElementById('timer_div').innerHTML = 'You are ready';
            clearInterval(interval);
        }
    }, 1000);
    

    Here is the Example

提交回复
热议问题