timer
HTML
<h1></h1>
CSS
h1{
color:#333;
background:springgreen;
text-align:center;
}
JavaScript
var txt = document.querySelector("h1");
var count = 0;
var timer;
function counter(){
txt.innerHTML=count;
count ++;
if(count==321){
clearInterval(timer);
}
}
function r(){
timer= setInterval(counter,1000);
}
r();