Skip to content

Instantly share code, notes, and snippets.

@mrcave
Created October 9, 2020 03:35
Show Gist options
  • Save mrcave/4f81d3fd03cd068ff0850e0f29d30add to your computer and use it in GitHub Desktop.
Save mrcave/4f81d3fd03cd068ff0850e0f29d30add to your computer and use it in GitHub Desktop.
Replace default mobile dropodown events in Divi
// Default Divi mobile menu dropdown events weren't working for us (didn't want the slideDown/Up functionality),
// so replaced it with our own events. We actually opted to use the .closed/.opened classes to hide and show our
// nav, but this snippet is a complete drop-in replacement for Divi's mobile dropdowns without needing additional CSS.
//unbind existing events on the mobile nav toggle
jQuery('.mobile_nav').off();
jQuery(".mobile_menu_bar").click(function(event){
e = jQuery(this);
s = jQuery(this).closest('.mobile_nav');
m = jQuery(".et_mobile_menu");
if(s.hasClass("closed")){
e.removeClass("closed").addClass("opened");
s.removeClass("closed").addClass("opened");
m.show();
} else {
e.removeClass("opened").addClass("closed")
s.removeClass("opened").addClass("closed");
m.hide();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment