为什么会报错?document.getElementById('count').value=num;这句话不对?
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>计时器</title> <script type="text/javascript"> var num=0; function startCount() { document.getElementById('count').value=num; num=num+1; setTimeout("startCount()",1000); } startCount(); </script> </head> <body> <form> <input type="text" id="count" /> </form> </body> </html>
VM1245:4 Uncaught TypeError: Cannot set property 'value' of null
at startCount (<anonymous>:4:43)
at <anonymous>:8:3
at g (ceditor.js?v=201807191446:1)
at v.runCode (ceditor.js?v=201807191446:1)
at Object.success (ceditor.js?v=201807191446:1)
at c (jquery.js?v=201807191446:2)
at Object.fireWith [as resolveWith] (jquery.js?v=201807191446:2)
at k (jquery.js?v=201807191446:4)
at XMLHttpRequest.r (jquery.js?v=201807191446:4)