Here is a link to an Accordion Menu I have created: https://jsfiddle.net/wfr57s57/
This piece of JQuery Code controls the functionality:
$(".menu-item").click(function(e) {
var allContents = $(".menu-content");
e.preventDefault();
if(allContents.hasClass("activeMenu")) {
allContents.removeClass("activeMenu");
}
var content = $(this).next().find(".menu-content");
content.toggleClass("activeMenu");
});
While it works well, I am looking for a way to make it such that clicking on a new menu item will slide up any open content before displaying the new one.
If you have any suggestions or improvements on this solution, please feel free to share. Thank you! :)