javascript - Is there any reference to the selected element in a delegated 'on' handler? -
javascript - Is there any reference to the selected element in a delegated 'on' handler? -
when using jquery on, there way selected element within handler, opposed event target? example, none of next related body:
$('body').on('click', 'h1', function(e){ console.log(e.target); console.log(e.currenttarget); console.log(this); });
the value of e.delegatetarget in event handler element handled event in illustration <body> tag.
as looks know, e.target set object originated event (might kid object in <h1>) , e.currenttarget , this set object matches "h1" selector.
most of time, it's object matches <h1> selector want, can utilize e.delegatetarget if want know object intercepted event.
jquery documentation reference: http://api.jquery.com/event.delegatetarget/
javascript jquery event-delegation
Comments
Post a Comment