问答详情
源自:2-4 IE事件处理程序及跨浏览器解决

为什么我还每点击按钮就自动打开网页了!

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

</head>

<body>

<input type = "button" id ="btn1" value = "按钮一">

<script>

function show(){

alert('Hello')

}

var btn1 = document.getElementById('btn1')

btn1.attachEvent('onclick',show());

</script>

</body>

</html>



提问者:慕粉547471488 2016-10-14 21:44

个回答