<input type="button" value="input" id="myInput">
window.onload=function (){
document.getElementsByTagName('input')[0].onclick = function(e){
alert("hello ");
}
}
我自己犯得错误
1:把onclick写成了onClick(好久没有写原生了)
2:直接document.getElementsByTagName('input').onclick ...
(因为document.getElementsByTagName获取的是dom列表,所以必须要有索引)