JavaScript API

jQuery events are fired each time a flyout or mega menu is open and closed. The events are “open_panel” and “close_panel”. You can also manipulate the menu (open and close sub menus) using JavaScript. It is also possible to directly call the plugin functions to open and close panels.

Examples

To use these examples, install the “TC Custom JavaScript” plugin, then paste one of the following options into the Appearance > Custom JavaScript page.

If you would prefer to use the examples below in your own JavaScript file, you must make sure it is output after the maxmegamenu.js file. Make sure “megamenu” is added as a dependency to “wp_enqueue_script”.

Detect when any sub menu is opened:

Detect when any sub menu is closed:

Detect when a sub menu for a specific menu item is opened:

Detect when a sub menu for a specific menu item is closed:

Close all open sub menus:

Close a single sub menu:

Open a single sub menu:

Remove focus from menu items when a sub menu is closed:

Remove focus from inputs when a sub menu is closed:

Related Articles