anavdesign
4/22/2016 - 3:37 AM

JS: Count Class Nested UL

JS: Count Class Nested UL

/*
 * Add Level Class Names to UL
 * See @ http://stackoverflow.com/questions/22354403/add-count-classes-for-nested-list-elements-with-jquery#answer-22354436 
 */

$('body ul').addClass(function() {
   return "js-level-"+$(this).parents('ul').length;
});