<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="box">1233</div>
<button id="demo">点击我</button>
</body>
<script>
var selectedBrow= {
addFun:function (element, type,handle ){
if(element.addEventListener) {element.addEventListener(type,handle,false)}
else if(element.attachEvent) {element.attachEvent("on"+type,handle)}
else{element["on"+type]=null}//??
},
removeFun:function(element,type,handle){
if(element.removeEventListener) {element.removeEventListener(type,handle,false)}
else if(elsment.detachEvent) {element.detachEvent("on"+type,handle)}
else{element["on"+type]=null }???
为什么不可以这小样写element.("om"+type)=null
}
};
var demo=document.getElementById("demo");
var handle=function(){
alert("我已经被点击。");
};
selectedBrow.addFun(demo,"click",handle);
// selectedBrow.removeFun(demo,"click",handle);
</script>
</html>
2018-01-25 22:25:00
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星