网问答>>为什么我的setinterval只执行了一次?
问题
已解决

为什么我的setinterval只执行了一次?

时间:2018-06-05 13:48:36
script type="text/javascript" window.onload = function() { var go = document.getElementById(go); var box = document.getElementById(box); go.onclick = function() { setInterval("hello()", 1000) } } function hello() { box.innerHTML = "hello" + " "; } /script /head body button id="go"开始/button div id="box" style="width: 200px; height: 200px; background-color: aquamarine;"/div /body
最佳回答
因为dom完全载入后..document.write是对整个dom进行了重写~~ script type="textjavascript" var i = 0; function olol() { ++i; document.write(i); } setInterval(olol, 3000); script
时间:2018-06-05 13:48:42
运行一次用setTimeOut
时间:2018-06-05 13:48:43
本类最有帮助
Copyright © 2008-2013 www.wangwenda.com All rights reserved.冀ICP备12000710号-1
投诉邮箱: