Skip to content

Instantly share code, notes, and snippets.

@uddhabh
Last active December 8, 2020 13:11
Show Gist options
  • Save uddhabh/603c38ac27d3d0af0537c0e32289dc4f to your computer and use it in GitHub Desktop.
Save uddhabh/603c38ac27d3d0af0537c0e32289dc4f to your computer and use it in GitHub Desktop.
Mobile Collapsing Nested Menu
.et_mobile_menu .first-level > a {
background-color: transparent;
position: relative;
}
.et_mobile_menu .first-level > a:after {
font-family: 'ETmodules';
content: '\4c';
font-weight: normal;
position: absolute;
font-size: 16px;
top: 13px;
right: 10px;
}
.et_mobile_menu .first-level > .icon-switch:after {
content: '\4d';
}
.second-level {
display: none;
}
.reveal-items {
display: block;
}
.et_mobile_menu {
margin-top: 20px;
width: 230%;
margin-left: -65%;
}
// https://www.elegantthemes.com/blog/divi-resources/how-to-create-a-mobile-collapsing-nested-menu-with-divis-theme-builder
(function ($) {
function setup_collapsible_submenus() {
var FirstLevel = $('.et_mobile_menu .first-level > a');
FirstLevel.off('click').click(function () {
$(this).attr('href', '#');
$(this).parent().children().children().toggleClass('reveal-items');
$(this).toggleClass('icon-switch');
});
}
$(window).load(function () {
setTimeout(function () {
setup_collapsible_submenus();
}, 700);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment