eve.delegateTarget | jQuery API 3.2 中文文档 | jQuery API 在线手册

jQuery API 3.2.1

推荐办理招商信用卡,新户首刷礼,五折享美食,需要的速度围观~click here
首页  >  事件对象  > eve.delegateTarget 源码下载

返回值: Elementevent.delegateTarget



此属性是最经常有用是通过过.delegate() 或.on()附加委派的事件,事件处理程序附加在正在处理的元素的祖先上。它可用于,例如,指明委派识别和删除事件处理程序。 This property is most often useful in delegated events attached by .delegate() or .on(), where the event handler is attached at an ancestor of the element being processed. It can be used, for example, to identify and remove event handlers at the delegation point.

对于非授权的事件处理程序,直接连接到一个元素,event.delegateTarget 总是等价于event.currentTarget.



When a button in any box class is clicked, change the box's background color to red.

jQuery 代码:
$(".box").on("click", "button", function(event) {
  $(event.delegateTarget).css("background-color", "red");