Sunday, 16 April 2017

SetTimeout and setInterval the first parameter plus no parentheses, plus no double quotes

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var num=0;
function numCount(){
 document.getElementById('txt').value=num;
 num=num+1;
 setTimeout(numCount(),1000);
 }

</script>
</head>
<body>
<form>
<input type="text" id="txt" />
<input type="button" value="Start" onClick="numCount()" />
</form>
</body>
</html>

Why do you want to add parentheses to the first parameter in the above code, and why do you add a double quotation mark in the seTimeout? What about setInterval?



via HopeVerse

No comments:

Post a Comment