How to display a running counter (1...2...3...4) in JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
  
<head></head>
  
<body>

<p id="p-id"></p>
<script>

setInterval(function () {count()}, 1000);

var counter = 0;

function count() 
{
    counter++;
    document.getElementById("p-id").innerHTML = counter;
}

/*
run:
 
1 ... 2  ... 3  ...
   
*/

</script>

</body>
  
</html>

 



answered Jul 22, 2015 by avibootz
...