Skip to content

Instantly share code, notes, and snippets.

@whoisryosuke
Created September 16, 2019 18:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoisryosuke/ff6fe8439bcc4cd67182389d6e9db6c1 to your computer and use it in GitHub Desktop.
Save whoisryosuke/ff6fe8439bcc4cd67182389d6e9db6c1 to your computer and use it in GitHub Desktop.
JS - Get attribute of event target (e.g. get href on click)
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