Topic: MDB Tab Events
Andrew Ford priority asked 1 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.
Kamila Pieńkowska staff answered 1 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.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.3.1
- Device: N/A
- Browser: N/A
- OS: N/A
- Provided sample code: Yes
- Provided link: No