Skip to content

Instantly share code, notes, and snippets.

@mantismamita
Created January 30, 2018 10:39
Show Gist options
  • Save mantismamita/0fb236ef324831ce83affd84797ceea2 to your computer and use it in GitHub Desktop.
Save mantismamita/0fb236ef324831ce83affd84797ceea2 to your computer and use it in GitHub Desktop.
ES6 only (due to Array.from())
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