Created
June 1, 2019 03:00
-
-
Save delacruzjames/a2ab1238c076320b17fcb91f236e6092 to your computer and use it in GitHub Desktop.
maxdepth,js
This file contains hidden or 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 maxDepth() { | |
var maxDep = 0, | |
d, | |
parents, | |
myselector = 'ul, ol'; | |
$(myselector).each( function(i) { | |
parents = $(this).parents(myselector); | |
d = parents ? parents.length + 1 : 1; | |
maxDep = d > maxDep ? d : maxDep; | |
}); | |
return maxDe; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment