Skip to content

@click.capture is not working for me. #12794

Answered by LinusBorg
heppa asked this question in Help/Questions
Discussion options

You must be logged in to vote

The code is working as expected, by event.target gives you the element that caused the event, which is the div, as that was what you clicked on.

What you want is event.currentTarget, which is the element that the event handler was attached to.

The currentTarget read-only property of the Event interface identifies the element to which the event handler has been attached.

This will not always be the same as the element on which the event was fired, because the event may have fired on a descendant of the element with the handler, and then bubbled up to the element with the handler. The element on which the event was fired is given by Event.target.

https://developer.mozilla.org/en-US/docs/W…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@heppa
Comment options

Answer selected by heppa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants