3👍
✅
Use event.currentTarget.getAttribute('data-action')
to grab the data*
attribute from where the event listener is bound. event.currentTarget
will always be the element the event listener is bound to (rather than the element that actually initiated the click
event, which is what event.target
points to).
Source:stackexchange.com