Created
January 30, 2018 10:39
-
-
Save mantismamita/0fb236ef324831ce83affd84797ceea2 to your computer and use it in GitHub Desktop.
ES6 only (due to Array.from())
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
let findChildWithClass = (parent, classname) => { | |
let children = Array.from(parent.children) | |
for (let child of children) { | |
if (child.classList.contains(classname)) { | |
return child | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment