Topic: Scrollspy not working

devtrix pro asked 2 years ago

First I tried adding the data attributes to the body element just as described i the API. I also assigned an id to the nav. I got Uncaught DOMException: Failed to execute 'querySelector' on 'Document'. I then used the Javascript initialization. I have tried straign up in a script tag and also in the like this.

 document.addEventListener("DOMContentLoaded", function(){
    const scrollSpy = new mdb.ScrollSpy(document.body, {
      target: '#main-nav'

Although I get no errors in the console, I dont see the active class being added.

Grzegorz Bujański staff answered 2 years ago

We need more information to resolve this issue. Please add the rest of the code. It will be best if you provide the minimal code version of the HTML file where this problem will occur + the JS and CSS code you are using there.

Please insert min. 20 characters.


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



Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.1
  • Device: All
  • Browser: ALL
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No