The dropdown menu is designed with CSS and HTML/JS using a class called "is-open" that is added from JS. Once present inside the HTML div specified, it will activate the CSS to display the submenu.
However there is a small issue wherein the dropdown menu once clicked will not disappear unless the same menu item is clicked. (The class will not de-toggle when clicking outside the menu-content div)
As a basic functionality this menu needs to disappear once a user clicks not just on the menu, but anywhere on the page.
My present javascript is the following:
$(document).ready(function() {
$(".has-submenu").click(function(e) {
e.stopPropagation();
if($(this).hasClass("is-open")) {
$(this).removeClass("is-open");
} else {
$(".has-submenu").removeClass("is-open");
$(this).addClass("is-open");
}
});
});
Here is a codepen example of the code: https://codepen.io/anon/pen/EwMjrz