V
V
Valentina2018-01-30 00:02:18
Bootstrap
Valentina, 2018-01-30 00:02:18

How to make the menu in bootstrap in the mobile version close when clicking on an item from the menu?

Single page site on Wordpress. There is a standard menu. Fixed and not scrolling. Links are seen as anchors on the same page.

;(function($) {
    "use strict";

// toggle menu for mobile
function mobileDropdown () {
  if($('#mega-menu-wrapper').length) {
    $('#mega-menu-wrapper .nav li.dropdown-holder').append(function () {
      return '<i class="fa fa-angle-down" aria-hidden="true"></i>';
    });
    $('#mega-menu-wrapper .nav li.dropdown-holder .fa').on('click', function () {
      $(this).parent('li').children('ul').slideToggle();
    });
  }
}

// DOM ready function
jQuery(document).on('ready', function() {
  mobileDropdown ();
});

})(jQuery)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tyzberd, 2018-01-30
@tyzberd

are you talking about this menu? https://getbootstrap.com/docs/3.3/examples/navbar/
there is a button with the navbar-toggle class
for calling $(".navbar-toggle").trigger("click");
just before that you need to check if this is a mobile version. This can be done by checking whether the menu has a class in.
4th grade may be different.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question