timer

by ian_smithz

HTML

<div id="counter">
60
</div>

JavaScript

var timer;
var count = 60;

$("#counter").text(count);
//update display

timer = setTimeout(update, 1000);
//this allows for 'clearTimeout' if needed

function update()
{
    if (count > 0)
    {
       $("#counter").text(--count);
       timer = setTimeout(update, 1000);
    }
    else
    {
        alert("Done!!!");
    }
}