<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列表,所以必須要有索引)