You need to delegate
Note I moved the show to the modal and gave the links a data attribute to point at the relevant video.
You COULD just change the video source and have ONE modal
document.getElementById('container').addEventListener("click", function(e) {
const tgt = e.target;
if (tgt.matches(".btn")) {
document.getElementById(tgt.dataset.id).classList.add("show")
} else if (tgt.matches(".close")) {
tgt.closest(".modal").classList.remove("show")
}
})
.btn {
text-decoration: none;
padding: 15px 40px;
background-color: #fff;
color: #000000;
border-radius: 40px;
font-family: 'Century Gothic';
font-weight: bolder;
}
.modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99999;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
pointer-events: none;
transition: all 0.3s;
}
.modal .close {
position: absolute;
top: 10px;
right: 25px;
font-size: 20px;
cursor: pointer;
}
.modal video {
width: 90%;
max-width: 800px;
transform: scale(0);
box-shadow: 0 20px 20px rgba(0, 0, 0, 0.2);
outline: none;
transition: all 0.3s;
}
.modal.show {
pointer-events: all;
opacity: 1;
}
.modal.show video {
transform: scale(1);
}
.btn {
text-decoration: none;
padding: 15px 40px;
background-color: rgb(255, 122, 0);
color: #fff;
border-radius: 40px;
font-family: 'Century Gothic';
font-weight: bolder;
box-shadow: 0 10px 40px rgba(255, 122, 0, 0.4);
}
<div id="container">
<div class="content active">
<h1>Cristiano Ronaldo</h1>
<p>Cristiano Ronaldo ist ein portugiesischer Fußballspieler, der seit Ende August 2021 zum zweiten Mal in seiner Karriere bei Manchester United unter Vertrag steht. </p>
<a href="#" class="btn" data-id="vid1"> Mehr... </a>
</div>
<div class="content">
<h1>Muhammad Ali</h1>
<p>Muhammad Ali war ein US-amerikanischer Boxer und der einzige, der den Titel des unumstrittenen Weltmeisters dreimal in seiner Karriere gewinnen konnte. Bekannt wurde er zunächst unter seinem Namen Cassius Clay. Er gehörte zu den bedeutenden Schwergewichtsboxern
und herausragenden Sportathleten des 20. </p>
<a href="#" class="btn" data-id="vid2"> Mehr... </a>
</div>
<div class="modal" id="vid1">
<div class="video-containere">
<span class="close"> ✖ </span>
<video src="CENSORED cause of private website" muted controls> </video>
</div>
</div>
<div class="modal" id="vid2">
<div class="video-container2">
<span class="close"> ✖ </span>
<video src="CENSORED cause of private website" muted controls> </video>
</div>
</div>
</div>