Hello I'm new to javascript, I'm using es6 to my code.
Basically, I have an issue with IE for addEventListener, the idea, when we click the image, pop up appears, it's working on chrome, but it doesn't work in IE. I know there's related topic already about this, ex: addEventListener in Internet Explorer
I tried to implement this, but it doesn't seem to work, I think I need to understand more how to implement it related to my code, if anyone could help, I'll really appreciate this.
const toggleButton = document.querySelector('.jsModalToggle');
const container = document.querySelector('.modal-yt-container');
toggleButton.addEventListener('click', _ => {
document.body.classList.add('modal-yt-is-open')
})
container.addEventListener('click', e => {
if (!e.target.closest('.modal-yt-video')) {
document.body.classList.remove('modal-yt-is-open')
}
})
.installation-video-callout-text-container {
padding: 20px;
}
.installation-video-callout-text p{
font-size: 1em;
line-height: 16px;
}
.installation-video-callout-text .green_btn{
margin: 20px 0 0px 0;
}
.installation-video-callout-text h2{
line-height: 45px;
font-size: 32px;
}
.installation-video-callout-img iframe{
height: 300px;
}
.modal-yt-container {
position: fixed;
display: flex;
justify-content: center;
align-items: center;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: 0;
z-index: -1;
background-color: rgba(0, 0, 0, 0.78);
}
.modal-yt-is-open .modal-yt-container {
z-index: 9999;
opacity: 1;
}
.modal-yt-video{
display: flex;
justify-content: center;
align-items: center;
width: 45%;
}
<img class="jsModalToggle installation-video-callout-img" src="image" style="cursor:pointer">image click</img>
<div class="modal-yt-container installation-video-callout-img">
<div class="modal-yt-video">
<iframe type="text/html"
width="100%"
height="500px"
src="https://www.youtube.com/embed/TA6blZJ6nVw"
frameborder="0">
</iframe>
</div>
</div>