zoukankan      html  css  js  c++  java
  • jQuery学习-事件之绑定事件(六)

    在jQuery中,为了屏蔽event对象在各浏览器中的差异性,它使用了自定的Event对象,如下:
     1 jQuery.Event = function( src, props ) {
     2     // Allow instantiation without the 'new' keyword
     3     //instanceof 用于判断一个变量是否某个对象的实例
     4     if ( !(this instanceof jQuery.Event) ) {
     5         return new jQuery.Event( src, props );
     6     }
     7 
     8     // Event object
     9     if ( src && src.type ) {
    10         /*
    11          如果是event对象
    12          * */
    13         this.originalEvent = src;//将原生的event对象存于Event中
    14         this.type = src.type;//事件类型
    15 
    16         // Events bubbling up the document may have been marked as prevented
    17         // by a handler lower down the tree; reflect the correct value.
    18         /*
    19          修正isDefaultPrevented方法
    20          * */
    21         this.isDefaultPrevented = src.defaultPrevented ||
    22                 src.defaultPrevented === undefined &&
    23                 // Support: IE < 9, Android < 4.0
    24                 src.returnValue === false ?
    25             returnTrue :
    26             returnFalse;
    27 
    28     // Event type
    29     } else {
    30         //如果event是事件名称
    31         this.type = src;
    32     }
    33 
    34     // Put explicitly provided properties onto the event object
    35     //赋值自定义属性
    36     if ( props ) {
    37         jQuery.extend( this, props );
    38     }
    39 
    40     // Create a timestamp if incoming event doesn't have one
    41     this.timeStamp = src && src.timeStamp || jQuery.now();//时间戳
    42 
    43     // Mark it as fixed
    44     this[ jQuery.expando ] = true;//标识event已被处理过
    45 };

    这个对象不复杂,对吧!

  • 相关阅读:
    adb root : adbd cannot run as root in production builds
    通过adb shell操作android真机的SQLite数据库
    基金--智能定投
    使用注册表优化终端、编辑器的中英字体混合显示,如「Consolas + 雅黑」「Monaco + 雅黑」
    诗词中的雨
    最好的PHP博客系统
    [重要更新][Quartus II][14.1正式版]
    解决Xilinx ISE在Win8下打开崩溃闪退的方法
    THE CUSTOMISER
    RAD Studio 2010~XE8 官方 ISO 下载地址 (2015-03-28更新)
  • 原文地址:https://www.cnblogs.com/urols-jiang/p/4339593.html
Copyright © 2011-2022 走看看