<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>計(jì)時(shí)器</title></head><script type="text/javascript">? var num=0;? function startCount() {? ? document.getElementById('count').value=num;? ? num=num+1;? ? setTimeout(startCount,1000);? }? ? document.write(num);</script></head><body><form><input type="text" id="count" onclick=startCount()/></form></body></html>比如這個(gè)例子
為啥要用setTimeout()循環(huán),直接用setInterval不是更好嗎??而且Settime啥時(shí)候結(jié)束調(diào)用??
北極的大熊
2017-01-19 10:29:46