Created
September 16, 2019 18:37
-
-
Save whoisryosuke/ff6fe8439bcc4cd67182389d6e9db6c1 to your computer and use it in GitHub Desktop.
JS - Get attribute of event target (e.g. get href on click)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
event = event || window.event; | |
var el = event.target || event.srcElement; | |
if (el instanceof HTMLAnchorElement) | |
{ | |
console.log(el.getAttribute('href')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment