Created
November 18, 2015 14:49
-
-
Save aubreypwd/748ba5958ae3fde694a2 to your computer and use it in GitHub Desktop.
Example of how to find the target/toElement localName
This file contains hidden or 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
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