timer count down

timer count down

by momenelkamri

HTML

<span id="timer"></span>

JavaScript

var count=30;

var counter=setInterval(timer, 1000); //1000 will  run it every 1 second

function timer()
{
  count=count-1;
  if (count <= 0)
  {
     clearInterval(counter);
      alert('it works');
     return;
  }

 document.getElementById("timer").innerHTML=count + " secs"; // watch for spelling
}