<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>事件流</title>
</head>
<body>
<input type="button" value="按钮" id="btn2" />
<script>
var btn2=document.getElementById("btn");
var ef={
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;
}
}
}
ef.addhandler(btn2,'click',function(){
alert('hello');
})
</script>
</body>
</html>