jQuery event.delegateTarget property
Examples
Change the <div> element's background color (<button> element ancestor):
$(event.delegateTarget).css("background-color", "pink");
});
try it"
Definition and Usage
event.delegateTarget property returns jQuery event handler is currently called the added element.
This attribute made on () method to add event delegates are very useful when the event handler is the ancestor element is processed to add.
Tip: If the event is bound directly to the elements and no commission occurs, event.delegateTarget equivalent event.currentTarget (see example below).
grammar
参数 | 描述 |
---|---|
event | 必需。 event 参数来自事件绑定函数。 |
More examples
and with different delegateTarget commissioned between currentTarget
DelegateTarget different presentation and occurs when a delegate currentTarget between.
For direct binding events, delegateTarget and currentTarget are equal
Demo for direct binding events, delegateTarget and currentTarget are equal.