Topic: Creating a select element with options
Steven Deferme free asked 3 years ago
Hello,
How can we create a select element with options in Javascript ?
const mySelect = new mdb.Select(document.getElementById('mySelect')) --> creates a select element, but how can I set the options (value + text) ?
Thanks
Dawid Wajszczuk staff answered 3 years ago
Hi,
You can set options by creating options element and appending it to Select element. Or you can still do this with simple HTML options. Here is the snippet with both approaches https://mdbootstrap.com/snippets/standard/d-wajszczuk/3532677#js-tab-view.
Keep coding,
Dawid
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: MDB5 3.10.1
- Device: PC
- Browser: Mozilla Firefox
- OS: Windows 10
- Provided sample code: No
- Provided link: No