问答详情
源自:8-5 计时器setTimeout()

为什么sum能无限循环加

<!DOCTYPE HTML>

<html>

<head>

<script type="text/javascript">

var num=0;

function numCount(){

 document.getElementById('txt').value=num;

 num=num+1;

 setInterval("numCount()",1000);

 }

</script>

</head>

<body>

<form>

<input type="text" id="txt" />

<input type="button" value="Start" onClick="numCount()" />

</form>

</body>

</html>


提问者:qq_曾婷红 2018-05-07 12:07

个回答

  • syousyou
    2018-05-07 13:24:41
    已采纳

    因为函数numCount()调用了自己