I'm trying to implement basic 60 sec counter(A p
element with idcounter
), that is triggered after a button(counter_start()
) is pressed.But I want delay of 1 sec between this and make sure this updates in browser window in real-time
<script type="text/javascript">
function counter_start(){
x=0
for(i=0;i<60;i++){
x++;
document.getElementById("counter").innerHTML=x;
}
}
</script>
P.S: There might be other simple methods of implementing a timer.But it's not about timer...actually I'm a student and trying to figure out the architecture and mechanism of this. EDIT: please post tested versions of the code, as some of em' posted below DO NOT update in real time