navbar-toggler does not close on in-page links.


Topic: navbar-toggler does not close on in-page links.

Hikeout design pro premium priority asked a year ago

I have a question about the smartphone menu (navbar-toggler). When you click the navbar-toggler button on an in-page link and then click the menu to change the page, navbar-toggler does not close. How do I make it disappear?

I am using the following sources. https://mdbootstrap.com/docs/standard/navigation/headers/


Hikeout design pro premium priority commented a year ago

以下のソースで解決しました。

document.querySelectorAll('.navbar-nav a').forEach(anchor => { anchor.addEventListener('click', function () { document.querySelector('.navbar-toggler').click(); }); });


Kamila Pieńkowska staff commented a year ago

Do you have additional questions?


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Open

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 7.0.0
  • Device: PC
  • Browser: chrome
  • OS: windows10
  • Provided sample code: No
  • Provided link: Yes