xxxxxxxxxx
1
<br>
2
<select class="select mySelect">
3
<option value="1">One</option>
4
<option value="2">Two</option>
5
<option value="3">Three</option>
6
<option value="4">Four</option>
7
<option value="5">Five</option>
8
</select>
9
<label class="form-label select-label">Example label</label>
1
1
xxxxxxxxxx
1
const select = document.querySelector('.mySelect')
2
const option = document.createElement('option')
3
option.value = 1
4
option.innerText = "option 1"
5
select.appendChild(option)
6
let mySelect
7
const instance = mdb.Select.getInstance(select)
8
if (instance) {
9
instance.dispose()
10
mySelect = new mdb.Select(select)
11
} else {
12
mySelect = new mdb.Select(select)
13
}
14
15
Console errors: 0