actionscript-3 actionscript event - Difference between e.target and e.currentTarget





5 Answers

e.target is what triggers the event dispatcher to trigger and e.currentTarget is what you assigned your listener to.

listener as3 mouse

I don't understand the difference, they both seem the same but I guess they are not.

Any examples of when to use one or the other would be appreciated.




I like visual answers.

When you click #btn, two event handlers get called and they output what you see in the picture.

Demo here: https://jsfiddle.net/ujhe1key/




make an example:

var body = document.body,
    btn = document.getElementById( 'id' );
body.addEventListener( 'click', function( event ) {
    console.log( event.currentTarget === body );
    console.log( event.target === btn );
}, false );

when you click 'btn', and 'true' and 'true' will be appeared!




  • e.target is element, which you f.e. click
  • e.currentTarget is element with added event listener.

If you click on child element of button, its better to use currentTarget to detect buttons attributes, in CH its sometimes problem to use e.target.




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.





Related