Skip to content

Instantly share code, notes, and snippets.

@evanleck
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanleck/98769b2f5e6354a8407b to your computer and use it in GitHub Desktop.
Save evanleck/98769b2f5e6354a8407b to your computer and use it in GitHub Desktop.
Simpler Handler
<a href='video_content'>Show Video</a>
<a href='about_content'>Show About</a>
<div id='video_content'>...</div>
<div id='about_content'>...</div>
document.addEventListener('click', function(clickEvent) {
// https://developer.mozilla.org/en-US/docs/Web/API/Event/target
var target = clickEvent.target;
// https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName
if (target.nodeName == 'A') {
// https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
clickEvent.preventDefault();
document.getElementById(target.href).style.visibility = "visible";
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment