Problems with mobile menu

Asked

Viewed 17 times

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. inserir a descrição da imagem aqui

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");
});
});
  • 1

    Guy posts minimal code that matches at least simulate his problems, include html and CSS

  • @hugocsl I’ll insert here per ai

  • @hugocsl I entered the link of the site in the description there to see what happens but look in the mobile version please

  • 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/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.