The setTimeout()
function runs only once. It is supposed to refresh every 100ms. but the youtube tutorial uses setTimeout. why is it not working in mine? is it not possible to use setTimeout for this application
<html>
<head>
<title>Stop Watch</title>
<script type="text/javascript">
var time=0;
var running=1;
function run(){
if(running==1){
setTimeout(function(){
time++;
document.getElementById("lead").innerHTML="Time: "+time;
},100);
}
}
</script>
</head>
<body>
<p id="lead">Click to start Timer</p>
<button id="startPause" onclick="run()">Start</button>
<button id="reset" onclick="">Reset</button>
</body>
</html>