求解JavaScript的DOM2级事件
<script>
function showMes(){
alert("Hello World!");
}
var btn3 = document.getElementById("btn3");
btn3.addEventListener("click", showMes(), false);
</script>
<input type="button" value="按钮3" id="btn3" />
这是源码,然后出错原因:
chrome版:Uncaught TypeError: Cannot read property 'addEventListener' of null
火狐版:TypeError: btn3 is null
我照着老师代码敲都能错?