i am trying to pop up a window including a video inside it . but using getElementById doesn't work for multiple videos using the same code. I am trying to use getElementByClass but it doesn't work for me. What am i missing ? Thanks in advance.
working code
var overlay = document.getElementById('overlay');
function openModal() {
overlay.classList.remove("is-hidden");
}
function closeModal() {
overlay.classList.add("is-hidden");
}
what i was trying to do (not working):
var overlay = document.getElementsByClassName('overlay');
my html:
<a class="buttonPlay" onclick="openModal();" href="#" style="visibility:visible;color:#ffffff;font-size:24px;">Play movie</a>
<div class="overlay is-hidden" id="overlay">
<a href="/" class="cancel">×</a>
<div class="video-responsive" style="overflow: visible; padding-bottom: 56.25%; position: relative; height: 0; top: 20%; left: 20%;">
<iframe src="@videoSrc" width="500" height="281" style=" left: 0; top: 0; height: 60%; width: 60%; position: absolute; " frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div>
</div>