Created
April 4, 2013 17:50
-
-
Save wilsonpage/5312507 to your computer and use it in GitHub Desktop.
Loops up the parent chain until a class match is found.
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
function parents(el, cl) { | |
while ((el = el.parentNode) && !~el.className.indexOf(cl)); | |
return el; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment