<html>
<head>
<title>三種加事件的方式</title>
<script language="javascript" type="text/javascript">
window.οnlοad=function(){
var arr = new Array(10);
for(var i = 0; i < arr.length; i ++){
arr[i]=i;
}
document.getElementById("but1").οnclick=function(){
alert("ok");
}
var butAdd2 = document.getElementById("but2");
butAdd2.onclick = function(){
alert("ok");
}
}
function butEvent(){
alert("ok")
}
</script>
</head>
<body>
<input type="button" value="測試1" id="but1"/>
<input type="button" value="測試2" id="but2"/>
<input type="button" value="測試3" id="but3" οnclick="butEvent()"/>
</body>
</html>
聯(lián)系客服