var webadd={
addtings:function(obj,type,hanshu){
if(obj.addEventListener){
obj.addEventListener(type,hanshu,false);
}
else if(obj.attachEvent){
obj.attachEvent('on'+type,hanshu)
}
else{
obj['on'+type]=hanshu;
}
},
removethings:function(obj,type,hanshu){
if(obj.removeEventListener){
obj.removeEventListener(type,hanshu,false);
}
else if(obj.detachEvent){
obj.detachEvent('on'+type,hanshu)
}
else{
obj['on'+type]=null;
}
}
}
var m=document.getElementById("maomao");
webadd.addtings(m,'click',go);
function go(){
this.style.background='black';
}
跨浏览器事件的添加与删除
最新推荐文章于 2021-04-26 18:50:30 发布