HiveBrain v1.2.0
Get Started
← Back to all entries
gotchajavascriptCritical

What is the exact difference between currentTarget property and target property in JavaScript?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
propertycurrenttargetandbetweenthedifferencetargetexactwhatjavascript

Problem

What is the exact difference between currentTarget and target property in JavaScript events with an example and which property is used in which scenario?

Solution

Events bubble by default. So the difference between the two is:

  • target is the element that triggered the event (e.g., the user clicked on)



  • currentTarget is the element that the event listener is attached to.

Context

Stack Overflow Q#10086427, score: 1100

Revisions (0)

No revisions yet.