zoukankan      html  css  js  c++  java
  • jQuery的delegate()与proxy()方法

    1. 

    jQuery 事件 - delegate() 方法

    定义和用法

    delegate() 方法为指定的元素(属于被选元素的子元素)添加一个或多个事件处理程序,并规定当这些事件发生时运行的函数。

    使用 delegate() 方法的事件处理程序适用于当前或未来的元素(比如由脚本创建的新元素)

    $("div").delegate("button","click",function(){
      $("p").slideToggle();
    });

    www.w3school.com.cn/jquery/event_delegate.asp

    2. 

    The $.proxy method takes an existing function and returns a new one with a particular context.

    This method is often used for attaching events to an element where the context is pointing back to a different object.

    Tip: If you bind the function returned from $.proxy, jQuery will still unbind the correct function if passed the original. 

    http://www.w3schools.com/jquery/event_proxy.asp

    ----

    this.$el.delegate('tbody tr', 'click', $.proxy(this._clickRow, this));
  • 相关阅读:
    第八章
    第十章
    第九章
    第七章
    第六章
    第五章
    第四章心得
    第二章心得
    第三章心得
    第一章心得
  • 原文地址:https://www.cnblogs.com/simoncook/p/4852967.html
Copyright © 2011-2022 走看看