Skip to content

Instantly share code, notes, and snippets.

@jkap
Created June 27, 2011 19:34
Show Gist options
  • Save jkap/1049621 to your computer and use it in GitHub Desktop.
Save jkap/1049621 to your computer and use it in GitHub Desktop.
/**
Returns the nesting level
-1 if not in a ul
0 if root
>0 if nested
*/
function detectNesting(selector, count) {
if(!count) { var count = -1; }
if ($(selector).parent().is("ul"))
{
return detectNesting(selector, count + 1);
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment