MDB Tab Events

Andrew Ford pro premium priority asked a year ago

I have 4 tabs;

  • #nearMeTab
  • #friendsTab
  • #everyoneTab
  • #myChatterTab

I only want to save either "nearMeTab", "friendsTab", or "everyoneTab" in the database.

To ensure the user can come back to the last tab they visited, I need to use document.querySelectorAll() - but I am getting the following error;

Uncaught TypeError: document.querySelectorAll(...).addEventListener is not a function

By using document.querySelector(), only the first tab's ID gets saved.


kpienkowska staff answered a year ago

document.querySelectorAll() results in an array and you cannot addEventListener to an array. You have to iterate through all elements in the array and addEventListener to every single one.


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
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 6.3.1
  • Device: N/A
  • Browser: N/A
  • OS: N/A
  • Provided sample code: No
  • Provided link: No
Tags