Created
January 27, 2017 00:32
-
-
Save a-axton/ed0dc157a782bd8fec03e2e60debcaa9 to your computer and use it in GitHub Desktop.
DOM walker to return parent that has specific class
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
| getInputParent (el) { | |
| const walk = (node) => { | |
| if (node.parentNode) { | |
| if (node.parentNode.classList.contains('input')) { | |
| return node.parentNode; | |
| } else { | |
| return walk(node.parentNode); | |
| } | |
| } | |
| } | |
| return walk(el); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment