0
People I have a problem in the side menu I created in the mobile version of my website needed that when the person opened the menu and clicked out it would close as shown in the image below, in case it doesn’t happen currently and I don’t know why it follows my script that makes the menu work.
JS:
jQuery(function ($) {
$(".sidebar-dropdown > a").click(function() {
$(".sidebar-submenu").slideUp(200);
if (
$(this)
.parent()
.hasClass("active")
) {
$(".sidebar-dropdown").removeClass("active");
$(this)
.parent()
.removeClass("active");
} else {
$(".sidebar-dropdown").removeClass("active");
$(this)
.next(".sidebar-submenu")
.slideDown(200);
$(this)
.parent()
.addClass("active");
}
});
$("#close-sidebar").click(function() {
$(".page-wrapper").removeClass("toggled");
});
$("#show-sidebar").click(function() {
$(".page-wrapper").addClass("toggled");
});
});
Guy posts minimal code that matches at least simulate his problems, include html and CSS
– hugocsl
@hugocsl I’ll insert here per ai
– Felipe Henrique
@hugocsl I entered the link of the site in the description there to see what happens but look in the mobile version please
– Felipe Henrique
Without your code you can’t help much, but this duplicate question answers just that, and there’s a technique you can use in your code easily. Basically when you open the menu vc tb puts behind it a div covering the entire screen from below, if you click on it closes the menu https://answall.com/questions/365451/howto close menu-clicando-fora-ou-em-qualquer-part-da-page/
– hugocsl