HTML
xxxxxxxxxx
1
<div class="p-3">
2
<div class="mb-3">
3
<select class="select" id="select">
4
<option value="1">One</option>
5
<option value="2">Two</option>
6
<option value="3">Three</option>
7
</select>
8
</div>
9
<button class="btn btn-danger">
10
Give me Red
11
</button>
12
<button class="btn btn-success">
13
Give me Green
14
</button>
15
<button class="btn btn-secondary">
16
I hate those color
17
</button>
18
</div>
CSS
1
1
JS
xxxxxxxxxx
1
const select = document.getElementById('select');
2
const [btnRed,btnGreen,btnReset] = document.querySelectorAll('button.btn')
3
4
btnRed.onclick = e => {
5
select.closest('.select-wrapper').querySelector('.select-input').classList.remove('is-valid');
6
select.closest('.select-wrapper').querySelector('.select-input').classList.add('is-invalid');
7
};
8
9
btnGreen.onclick = e => {
10
select.closest('.select-wrapper').querySelector('.select-input').classList.add('is-valid');
11
select.closest('.select-wrapper').querySelector('.select-input').classList.remove('is-invalid');
12
};
13
14
btnReset.onclick = e => {
15
select.closest('.select-wrapper').querySelector('.select-input').classList.remove('is-valid');
16
select.closest('.select-wrapper').querySelector('.select-input').classList.remove('is-invalid');
17
};
18
console.log(mdb.Select.prototype)
Console errors: 0