Skip to content
Advertisement

JS Toggle Submenu within Mega Menu

The issue I’m having is, creating a submenu inside another menu.

Demo: LIVE DEMO (Important, cause CSS is needed as well

JavaScript

I’m having this Bootstrap Mega Menu, which also contains a submenu (Column 2). On click, it should hide Column 3, and show the submenu items. (it does its job)

Currently, I’m grabbing the submenu content with jquery html() and then placing it on the third column (probably not the cleanest method).

The problem: whenever I close a submenu and click again, it won’t open back.

Advertisement

Answer

It looks like currently, the active class isn’t removed on the second click. Instead, it just clears out the HTML of column three. We could fix that by adding a line to remove the active class when we hide the submenu.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement