返回值: Elementevent.delegateTarget

V1.7概述

当currently-called的jQuery事件处理程序附加元素。

此属性是最经常有用是通过过.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");
});
<<返回首页<<返回首页