jquery四种监听事件的区别

最近找工作被问到了jquery有哪些事件监听,都有什么区别,忽然有点想不起来了。。。

然后上网上查看了相关的资料,总结一下,方便大家查看,也方便自己复习!

  1.bind()方法:

    bind(type,[data],function(event));

    参数:type:事件类型;

    data:传入监听函数的参数;

    function:监听函数, event为jquery封装的event;

    bind()源码:

      bind:function(type,data,fn){

        return this.on(type,data,fn);

      }  

    我们可以看到在bind的内部其实还是调运了on方法;

  2.live(type,data,fn)方法:

    live的参数和bind的参数是一样的;

    live的源码:

      live:function(){

        jQuery(this.context).on(types,this.selector,data,fn);

        return this;

      }

    

    

原文地址:https://www.cnblogs.com/haodoubao/p/8536362.html