如何获取 event.target/event.currentTarget for HTML-5 canvas for click handler

How to get event.target/event.currentTarget for HTML-5 canvas for click handler

我希望每个人都做得很好。

我属于 Actionscript 背景,刚开始使用 Flash CC HTML-5 canvas。如何在 Flash CC 中获取 event.targetevent.currentTarget for HTML-5 canvas for click event.

就像我们以前在 AS 3.0 中做的那样:

btn.addEventListener(MouseEvent.CLICK , go);
function go(evt:MouseEvent) {
    trace(" evt - "+evt.currentTarget); // It will let us know the clicked target
}

对于HTML-5

btn.addEventListener('click' , go.bind(this));
function go(evt){
   console.log(" evt - "+evt.????t); // what is the correct syntax here?
}

谢谢,

您可以使用 evt.target.

另请参阅以下其他可能性:

document.querySelector("div").addEventListener("click", function(e) {console.log(e);});
<div>F12, then click here</div>