Topic: Add Class to Select
yorkmyers priority asked 8 months ago
Is it possible to add a class target the new HTML element that wraps this select?
mlazaru staff answered 8 months ago
Unfortunately currently there is no way pass class or ID for new created HTML element via atributes. I'll add this feature to our todo list, and it may be added in future.
For now I've prepared two workaround solutions based on your code:
1.Newly created input always has
.select-input class, so you can use
document.querySelector('.select-input'), or if you use more than one:
This isn't best aproach to be honest, because it reduces code readability.
2.If you add
data-mdb-placeholder, it will be passed to new Select element as
placeholder attribute. Use it as a selector for new Select element.
Both solutions are in snippet linked below, first one is commented out.
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 3.11.0
- Device: Desktop
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: Yes