表单元素点击事件改到script标签中就不能执行??
<!DOCTYPE HTML> <html> <head> <script type="text/javascript"> var num=0; // numCount(); function numCount(){ document.getElementById('txt').value=num; num=num+1; setTimeout("numCount()",1000); } </script> </head> <body> <form> <input type="text" id="txt" /> <input type="button" value="Start" onclick="numCount()" /> </form> </body> </html>
为什么我把onclick="numCount()"删除,然后在script标签中加上numCount()就报错,
提示cannot set property 'value' of null