zoukankan      html  css  js  c++  java
  • JS事件绑定

    // 事件绑定
            this.bindHandler = (function() {
                if (window.addEventListener) {// 标准浏览器
                    return function(elem, type, handler) {// elem:节点    type:事件类型   handler:事件处理程序
                        // 最后一个参数为true:在捕获阶段调用事件处理程序    为false:在冒泡阶段调用事件处理程序
                        elem.addEventListener(type, handler, false);
                    }
                } else if (window.attachEvent) {// IE浏览器
                    return function(elem, type, handler) {
                        elem.attachEvent("on" + type, handler);
                    }
                }
            })();
    
            // 事件解除
            this.removeHandler = (function() {
                if (window.removeEventListerner) {// 标准浏览器
                    return function(elem, type, handler) {
                        elem.removeEventListerner(type, handler, false);
    
                    }
                } else if (window.detachEvent) {// IE浏览器
                    return function(elem, type, handler) {
                        elem.detachEvent("on" + type, handler);
                    }
                }
            })();
  • 相关阅读:
    python字符串字典列表互转
    列表迭代器 ListIterator
    并发修改异常处理
    二月天 案例
    Calendar类
    Date类
    冒泡排序
    内部类
    python第三天
    Layui——checkbox使用
  • 原文地址:https://www.cnblogs.com/mishiyang/p/5501894.html
Copyright © 2011-2022 走看看