<!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)
你这个 input标签里面连 调用函数都没有 当然没东西了
是不是把13行去掉,18行后面插入<input type="button" value="Start" onClick="startCount()">