Skip to content

Instantly share code, notes, and snippets.

@aubreypwd
Created November 18, 2015 14:49
Show Gist options
  • Save aubreypwd/748ba5958ae3fde694a2 to your computer and use it in GitHub Desktop.
Save aubreypwd/748ba5958ae3fde694a2 to your computer and use it in GitHub Desktop.
Example of how to find the target/toElement localName
var t = false; // Default.
// Get the right target being clicked.
if ( 'target' in event ) {
t = event.target.localName; // Gecko
} else if ( 'toElement' in event && 'undefined' !== event.toElement ) {
t = event.toElement.localName; // Webkit
}
// If the target is an img, a, or li, it's a safe item in the menu.
if ( 'a' != t && 'li' != t && 'img' != t ) {
// Do my things as long as they are not these elements.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment