Skip to content

Instantly share code, notes, and snippets.

@wilsonpage
Created April 4, 2013 17:50
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 wilsonpage/5312507 to your computer and use it in GitHub Desktop.
Save wilsonpage/5312507 to your computer and use it in GitHub Desktop.
Loops up the parent chain until a class match is found.
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