手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >javascript之卸载鼠标事件的代码
javascript之卸载鼠标事件的代码
摘要://byxmgfunctionaddEvent(obj,eventName,eventFunc){if(obj.attachEvent){o...

//byxmg

<script>

functionaddEvent(obj,eventName,eventFunc){

if(obj.attachEvent){

obj.attachEvent(eventName,eventFunc);

}elseif(obj.addEventListener){

eventName=eventName.toString().replace(/on(.*)/i,'$1');

obj.addEventListener(eventName,eventFunc,true);

}

}

functiondelEvent(obj,eventName,eventFunc){

if(obj.detachEvent)

obj.detachEvent(eventName,eventFunc)

elseif(obj.removeEventListener){

eventName=eventName.toString().replace(/on(.*)/i,'$1');

obj.removeEventListener(eventName,eventFunc,true);

}

}

</script>

<HTML>

<HEAD>

<TITLE></TITLE>

</HEAD>

<BODY>

<buttononclick=addEvent(document,"onclick",test1)>add1</button><br>

<buttononclick=delEvent(document,"onclick",test1)>del1</button><br>

<buttononclick=addEvent(document,"onclick",test2)>add2</button><br>

<buttononclick=delEvent(document,"onclick",test2)>del2</button><br>

<script>

functiontest1(){

alert("test1")

}

functiontest2(){

alert("test2")

}

document.onclick=function(){

alert(1)

}

</script>

</BODY>

</HTML>

【javascript之卸载鼠标事件的代码】相关文章:

JavaScript中substring()方法的使用

javascript实现图片跟随鼠标移动效果的方法

javascript实现Table排序的方法

javascript正则表达式总结

JavaScript事件委托实例分析

javascript检测两个数组是否相似

javascript的事件描述

javascript每日必学之运算符

javasript实现密码的隐藏与显示

Javascript高级应用:文件操作篇

精品推荐
分类导航