Skip to content

Instantly share code, notes, and snippets.

@glaubercorreaarticle
Created February 23, 2018 17:32
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 glaubercorreaarticle/966fdf7efc9f30e26701532f2a56ec75 to your computer and use it in GitHub Desktop.
Save glaubercorreaarticle/966fdf7efc9f30e26701532f2a56ec75 to your computer and use it in GitHub Desktop.
let getClosestElement = function(element, classToSearch) {
if(!element) {
return false;
} else if(element && element.classList.contains(classToSearch)) {
return element;
} else {
return getClosestElement(element.parentElement, classToSearch);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment