首页 > Web开发 > 详细

jQuery的delegate()与proxy()方法

时间:2015-10-03 06:04:39      阅读:324      评论:0      收藏:0      [点我收藏+]

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));

 

jQuery的delegate()与proxy()方法

原文:http://www.cnblogs.com/simoncook/p/4852967.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!