Created
February 23, 2018 17:32
-
-
Save glaubercorreaarticle/966fdf7efc9f30e26701532f2a56ec75 to your computer and use it in GitHub Desktop.
This file contains 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 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