<body>
<div>
<input type="button" id="btn3" value="按钮" />
</div>
<script>
var eventUtil={
addHandel:function(element,type,handel){
if(element.addEventListener){
element.addEventListener(type,handel,false);
}else if(element.attachEvent){
element.attacheEvent("on"+type,handel);
}else{
element["on"+type]=handel;
}
},
removeHandel:function(element,type,handel){
if(element.removeEventListener){
element.removeEventListener(type,handel,false);
}else if(element.detachEvent){
element.detachEvent("on"+type,handel);
}else{
element["on"+type]=null;
}
}
};
eventUtil.addHandel(btn3,click,function(){
alert("hello");
})
</script>
</body>
相关分类