Skip to content

Instantly share code, notes, and snippets.

@a-axton
Created January 27, 2017 00:32
Show Gist options
  • Select an option

  • Save a-axton/ed0dc157a782bd8fec03e2e60debcaa9 to your computer and use it in GitHub Desktop.

Select an option

Save a-axton/ed0dc157a782bd8fec03e2e60debcaa9 to your computer and use it in GitHub Desktop.
DOM walker to return parent that has specific class
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