Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Scrollspy not working

devtrix pro asked 3 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 3 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.

FREE CONSULTATION

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

Status

Answered

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