xxxxxxxxxx
1
<!-- Modal gallery -->
2
<section class="container my-5">
3
<!-- Section: Images -->
4
<section class="">
5
<div class="row">
6
<div class="col-lg-4 col-md-12 mb-4 mb-lg-0">
7
<div
8
class="bg-image hover-overlay ripple shadow-1-strong rounded"
9
data-ripple-color="light"
10
>
11
<img
12
src="https://mdbcdn.b-cdn.net/img/screens/yt/screen-video-1.webp"
13
class="w-100"
14
/>
15
<a href="#!" data-mdb-modal-init data-mdb-target="#exampleModal1">
16
<div class="mask" style="background-color: rgba(251, 251, 251, 0.2);"></div>
17
</a>
18
</div>
19
</div>
20
21
<div class="col-lg-4 mb-4 mb-lg-0">
22
<div
23
class="bg-image hover-overlay ripple shadow-1-strong rounded"
24
data-ripple-color="light"
25
>
26
<img
27
src="https://mdbcdn.b-cdn.net/img/screens/yt/screen-video-2.webp"
28
class="w-100"
29
/>
30
<a href="#!" data-mdb-modal-init data-mdb-target="#exampleModal2">
31
<div class="mask" style="background-color: rgba(251, 251, 251, 0.2);"></div>
32
</a>
33
</div>
34
</div>
35
36
<div class="col-lg-4 mb-4 mb-lg-0">
37
<div
38
class="bg-image hover-overlay ripple shadow-1-strong rounded"
39
data-ripple-color="light"
40
>
41
<img
42
src="https://mdbcdn.b-cdn.net/img/screens/yt/screen-video-3.webp"
43
class="w-100"
44
/>
45
<a href="#!" data-mdb-modal-init data-mdb-target="#exampleModal3">
46
<div class="mask" style="background-color: rgba(251, 251, 251, 0.2);"></div>
47
</a>
48
</div>
49
</div>
50
</div>
51
</section>
52
<!-- Section: Images -->
53
54
<!-- Section: Modals -->
55
<section class="">
56
<!-- Modal 1 -->
57
<div
58
class="modal fade"
59
id="exampleModal1"
60
tabindex="-1"
61
aria-labelledby="exampleModal1Label"
62
aria-hidden="true"
63
>
64
<div class="modal-dialog modal-lg">
65
<div class="modal-content">
66
<div class="ratio ratio-16x9">
67
<iframe
68
src="https://www.youtube.com/embed/A3PDXmYoF5U?enablejsapi=1"
69
title="YouTube video"
70
allowfullscreen
71
></iframe>
72
</div>
73
</div>
74
</div>
75
</div>
76
<!-- Modal 2 -->
77
<div
78
class="modal fade"
79
id="exampleModal2"
80
tabindex="-1"
81
aria-labelledby="exampleModal2Label"
82
aria-hidden="true"
83
>
84
<div class="modal-dialog modal-lg">
85
<div class="modal-content">
86
<div class="ratio ratio-16x9">
87
<iframe
88
src="https://www.youtube.com/embed/wTcNtgA6gHs?enablejsapi=1"
89
title="YouTube video"
90
allowfullscreen
91
></iframe>
92
</div>
93
</div>
94
</div>
95
</div>
96
<!-- Modal 3 -->
97
<div
98
class="modal fade"
99
id="exampleModal3"
100
tabindex="-1"
101
aria-labelledby="exampleModal3Label"
102
aria-hidden="true"
103
>
104
<div class="modal-dialog modal-lg">
105
<div class="modal-content">
106
<div class="ratio ratio-16x9">
107
<iframe
108
src="https://www.youtube.com/embed/vlDzYIIOYmM?enablejsapi=1"
109
title="YouTube video"
110
allowfullscreen
111
></iframe>
112
</div>
113
</div>
114
</div>
115
</div>
116
</section>
117
<!-- Section: Modals -->
118
</section>
119
<!-- Modal gallery -->
1
1
xxxxxxxxxx
1
const modalEl1 = document.querySelector('#exampleModal1')
2
const modalEl2 = document.querySelector('#exampleModal2')
3
const modalEl3 = document.querySelector('#exampleModal3')
4
5
modalEl1.addEventListener('hide.mdb.modal', () => {
6
const iframe = modalEl1.querySelector('iframe');
7
console.log(iframe)
8
iframe.contentWindow.postMessage('{"event":"command","func":"' + 'pauseVideo' + '","args":""}', '*');
9
})
10
11
modalEl2.addEventListener('hide.mdb.modal', () => {
12
const iframe = modalEl2.querySelector('iframe');
13
console.log(iframe)
14
iframe.contentWindow.postMessage('{"event":"command","func":"' + 'pauseVideo' + '","args":""}', '*');
15
})
16
17
modalEl3.addEventListener('hide.mdb.modal', () => {
18
const iframe = modalEl3.querySelector('iframe');
19
console.log(iframe)
20
iframe.contentWindow.postMessage('{"event":"command","func":"' + 'pauseVideo' + '","args":""}', '*');
21
})
Console errors: 0