Skip to content

Instantly share code, notes, and snippets.

@ButlerFuqua
Last active April 2, 2019 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ButlerFuqua/a2f0674c7d9751f74e58406611f99a6b to your computer and use it in GitHub Desktop.
Save ButlerFuqua/a2f0674c7d9751f74e58406611f99a6b to your computer and use it in GitHub Desktop.
function findAncester(el, cls) {
while (((el = el.parentElement) && !el.classList.contains(cls)) || el.tagName === "BODY");
return el;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment