Latest

6/recent/ticker-posts

Header Ads Widget

Timer countdown with javascript

 <div id="some_div"></div>


<script>

var timeLeft = 30;

var elem = document.getElementById('some_div');

var timerId = setInterval(countdown, 1000);


function countdown() {

    if (timeLeft == -1) {

        clearTimeout(timerId);

        doSomething();

    } else {

        elem.innerHTML = timeLeft + ' seconds remaining';

        timeLeft--;

    }

}


function doSomething() {

    alert("Hi");

}


</script>

Post a Comment

0 Comments