xxxxxxxxxx
1
<!-- Trigger buttons -->
2
<button type="button" class="btn btn-primary" id="basic-primary-trigger">Primary</button>
3
4
<!-- Toasts -->
5
<div
6
class="toast fade mx-auto"
7
id="basic-primary-example"
8
role="alert"
9
aria-live="assertive"
10
aria-atomic="true"
11
data-mdb-autohide="true"
12
data-mdb-delay="105"
13
data-mdb-position="top-right"
14
data-mdb-append-to-body="true"
15
data-mdb-stacking="true"
16
data-mdb-width="350px"
17
data-mdb-color="primary"
18
>
19
<div class="toast-header text-white">
20
<strong class="me-auto">MDBootstrap</strong>
21
<small>11 mins ago</small>
22
<button type="button" class="btn-close btn-close-white" data-mdb-dismiss="toast" aria-label="Close"></button>
23
</div>
24
<div class="toast-body text-white">Primary Basic Example</div>
25
</div>
26
1
1
xxxxxxxxxx
1
const toasts = [ 'basic-primary-example',
2
];
3
4
const triggers = [
5
'basic-primary-trigger',
6
];
7
8
triggers.forEach((trigger, index) => {
9
let basicInstance = mdb.Toast.getInstance(document.getElementById(toasts[index]));
10
document.getElementById(trigger).addEventListener('click', () => {
11
basicInstance.show();
12
});
13
});
Console errors: 0