Created
March 6, 2019 06:38
-
-
Save srph/a7e3ce7ff6109e6efcb767e10ae60de3 to your computer and use it in GitHub Desktop.
JS: Check if an element is under an anchor element
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
/** | |
* Check if an element is under an anchor element | |
*/ | |
function isDescendantOfAnchor(element) { | |
do { | |
if (element.tagName === 'A') { | |
return true | |
} | |
} while(element = element.parentNode) | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment