js中的onload事件为什么不能触发?

代码如下:<html> <head> <meta charset="utf-8" /> <script type="text/javascript"> document.getElementById("demo").onclick = function() { alert("feafeafasf"); } </script> </head> <body> <input id="demo" type="button" value="" /> </body></html>。。。。。然而并不能触发点击事件,不知是怎么回事。


守候你守候我
浏览 835回答 1
1回答

大话西游666

小兄弟,你把input写到body里面,document是html的对象,你把input写在了外面,他怎么读的到,而且input是html标签
打开App,查看更多内容
随时随地看视频慕课网APP