Simple Countdown Timer for Site?

Associate
Joined
31 Jan 2010
Posts
283
Location
UK
Hello Peeps,

I am after a simple Timer (displayed in text) for a website, simply counting down from 30 seconds then displaying a simple message (again in text). Then if the website is refreshed it will simply start again.

I have been looking round the net but can only find scripts that count down to a certain date/time.

Any ideas? It only needs to be really basic :)
 
Bit of JQuery, probably could be better but it works -
Code:
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    var countdown_from = 30;
    $("#countdown_div").html(countdown_from);
    var timer_id = setInterval(function() {
        countdown_from--;
        if (countdown_from <= 0) {
            clearInterval(timer_id);
            $("#countdown_div").html("END COUNTDOWN");
        } else {
            $("#countdown_div").html(countdown_from);
        }
    }, 1000);

});
</script>
<div id="countdown_div"></div>
</html>
 
Last edited:
Back
Top Bottom