zoukankan      html  css  js  c++  java
  • js 事件

    1. 事件冒泡 :  

    // 分别在 >= ie 9 和 < ie9 下测试

    'use strict';
    var arr = [document, window, document.documentElement, document.body, document.querySelector('.container')];
    while (arr.length){
      var e = arr.pop(arr);
      !function(e){
        if (e.addEventListener){
          e.addEventListener('click', function (event) {console.log(e.constructor.name);});
        }else{
          e.attachEvent('onclick', function (event) {console.log(e.constructor.name);});
        }
      }(e)
    }

    1. ie9 支持 elementTarget.addeventListener ,ie 9 以下不支持。

    2. 默认都是事件冒泡的方式

  • 相关阅读:
    20151019
    20151013
    20150810
    20150626
    20150625
    20150530
    HTML特殊字符大全
    label标签跳出循环
    IIS 负载均衡
    .NET代码执行效率优化
  • 原文地址:https://www.cnblogs.com/Tachi/p/7479874.html
Copyright © 2011-2022 走看看