Topic: How to create element dynamically?

KES free asked 2 years ago


Is there a way to create components dynamically?

like: new Select({ ...options })

Grzegorz Bujański staff answered 2 years ago

Yes, it is possible. First you need to add select HTML code, then init it:

const mySelect = new mdb.Select(document.getElementById('mySelect'), options)

Here you will find an example:

You can add other components dynamically in a similar way. In the API tab of the component documentation, you will find the JS code required to init the component

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: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.8.1
  • Device: no device
  • Browser: FF
  • OS: Linux mint 19.3
  • Provided sample code: No
  • Provided link: No