Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(function ($) {
Drupal.behaviors.menuTree = {
attach: function (context, settings) {
// Set ul depths for better theming.
$('#main-menu ul').each(function () {
var depth = $(this).parents('ul').length;
$(this).addClass('ul-depth-' + depth);
});
// Set ul > li depths for better theming.
$('#main-menu ul li').each(function () {
var depth = $(this).parents('li').length;
$(this).addClass('li-depth-' + depth);
});
// Set li > a depths for better theming.
$('#main-menu ul li a').each(function () {
var depth = $(this).parents('ul').length;
$(this).addClass('ula-depth-' + depth);
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment