<div id="countbox"></div> <script> var seconds=5 function display(){ if (seconds<=-1){ seconds+=1 } else { seconds-=1 document.getElementById('countbox').innerHTML=seconds setTimeout("display()",1000) } } display(); </script>