Created
June 10, 2020 22:58
-
-
Save waghcwb/902d13c67c10d62d5ec66ed69ee5d5a9 to your computer and use it in GitHub Desktop.
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
if (!Element.prototype.findParentTagName) { | |
Element.prototype.findParentTagName = function (stringData) { | |
try { | |
if (this.tagName.equal(stringData)) return this; | |
let parent = this.parentElement; | |
while (parent) { | |
if (parent.tagName.equal(stringData)) return parent; | |
parent = parent.parentElement; | |
} | |
} catch (e) { | |
return null; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment