JavaScript › DOM & Events
What's the difference between event.target and event.currentTarget?
IntermediateAnswer
event.target is the actual element that originated the event (e.g., the specific <li> clicked); event.currentTarget is the element the listener is currently attached to and executing on (e.g., the parent <ul> during bubbling).
list.addEventListener('click', (e) => {
console.log(e.target); // the <li> clicked
console.log(e.currentTarget); // the <ul> the listener is on
});Real-world example Using target to identify which specific button in a toolbar was clicked, while currentTarget stays constant.