<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>50</title>
</head>
<body>
<input type="button" value="按钮" id="bot1">
<script type="text/javascript">
var b1=document.getElementById("bot1");
var addHandle={
add: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]=handle;
}
},//为什么要加逗号。
remove:function(element,type,handle){
if(element.removeEventListener){
element.removeEventListener(type,handle,false);
}
else if(element.detachEvent){
element.detachEvent("on"+type,handle);
}
else{
element["on"+type]=null;
}
}
}
function my_a(){
alert("Hello");
}
addHandle.add(bot1,"click",my_a);
//addHandle.remove(bot1,"click",my_a);
</script>
</body>
</html>
Yanzu
追觅梦初的国度
好人理查德
相关分类