event.currentTarget

event.currentTarget

  • JavaScript property (not specific to jQuery) that identifies the current target for the event

  • It always refers to the element to which the event handler has been attached, as opposed

  • Similar to $(this), with the added benefit that it works with arrow functions

  • When using event.currentTarget in the context of jQuery, it should be wrapped in a jQuery object: $(event.currentTarget)

Example

$(() => {
  $("#box").click((event) => {
    // use $(event.currentTarget) with with an arrow function
    // to reference the element that is being "acted on"
    $(event.currentTarget).fadeOut(1000)
  })
})

JS Bin on jsbin.com