Hey there! I need some assistance. Currently, I am working with Bootstrap 3.1.1 and implementing nested collapse menus in a sidenav. My goal is to apply a background color (using a specific class) to the open menu and remove it when the menu is closed.
Everything is functioning correctly, but I'm facing an issue with nested menus. The code I'm using removes the background color for the parent item when closing the child menu. I'm struggling to figure out how to only remove the background color if it's a top-level menu closure. In other words, the background color should not be removed when closing a child menu.
$(".nav-sidenav > li").on("show.bs.collapse", function () {
$(this).addClass("sidenav-active-background");
});
$(".nav-sidenav > li").on("hide.bs.collapse", function () {
$(this).removeClass("sidenav-active-background");
});
For reference, you can check out JSFiddle