Topic: JS to open a tab not working

launchbrigade priority asked 1 year ago

Expected behavior I use this code :

const triggerEl = document.querySelector('#in-the-news');
mdb.Tab.getInstance(triggerEl).show(); // Select tab by name

to open a tab

Actual behavior

Console Log Error

Uncaught TypeError: Cannot read properties of null (reading 'show')

Resources (screenshots, code snippets etc.)

if i add


i get


Dawid Wajszczuk staff answered 1 year ago


Here is the snippet Everything works fine. You probably use wrong selector or maybe your tabs are hidden during the page load and they need to be initialized manually.

Keep coding,

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

  • User: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: All
  • Browser: Chrome
  • OS: Mac 11.1
  • Provided sample code: No
  • Provided link: No