45行说是 Uncaught SyntaxError: Unexpected identifier .求助那个语法错误啊
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<body>
<div id="box">
<input type="button" value="click" id="btn1" onclick="show()">
<input type="button" value="click2" id="btn2">
<input type="button" value="click3" id="btn3">
<input type="button" value="click3" id="btn4">
</div>
<script>
function show(){
alert("hello");
}
var btn2=document.getElementById('btn2');
var btn3=document.getElementById('btn3');
/*var btn4=document.getElementById('btn4');
btn2.onclick=function(){
alert("DMO0");
}//DOM0
btn2.onclick=null;
btn3.addEventListener('click',show, false);//DOM2
btn3.addEventListener('click',function(){
alert(this.value );
}, false);
//btn3.removeEventListener('click',show, false);
btn4.attachEvent('onclick',show);
btn4.detachEvent('onclick',show);*/
var eventUtil={
//添加句柄
addHandler:function(element,type,handler){
if(element.addEventListener){
element.addEventListener(type,handler,false);
}else if(element.attachEvent){
element.attachEvent('on'+type,handler);
}else{
element['on'+type]=handler;
}
}
//删除句柄
removeHandler:function(element,type,handler){
if(element.removeEventListener){
element.removeEventListener(type,handler,false);
}else if(element.detachEvent){
element.detachEvent('on'+type,handler);
}else{
element['on'+type]=null;
}
}
}
eventUtil.addHandler(btn3,'click',show);
</script>
</body>
</head>
</html>