I have a page with a bunch of cards on it. I want a pop up to appear when a card is clicked. Ultimately, I would like to have the content of the pop up be different for each card, but for now I just want to get the pop up to work. I was able to get the javaScript code to work with getElementById, but that wont work as I have many different cards. Can someone help me get this javascript working?
Here is my HTML
<div class="cardContainer">
<div class="trainingCard">
<div class="cardText">
<h1>How to fill out a time card</h1>
<p> To learn out how to fill out a time card, click this card to acess a digital training lesson!</p>
</div>
</div>
<!-- next training card-->
<div class="trainingCard">
<div class="cardText">
<h1>How to change labels</h1>
<p> To learn out replace the labels in a labeler machine, click this card to acess a digital training lesson!</p>
</div>
</div>
<!-- next training card-->
<div class="trainingCard">
<div class="cardText">
<h1>How to insert a trigger</h1>
<p> To learn how to insert a trigger when working on a liquid filling line, click this card to access a digital training lesson!</p>
</div>
</div>
<!--end card container-->
</div>
<div class="popUpModal" id=popUpModal>
<div class="popUpContent">
<div class="close">+</div>
<h1 class="trainingPopUpHeader">How to Change Labels</h1>
<div class="trainingPopUpDescription">
<p>When the labeler machine runs out of labels, it is up to one of the associates to replace the labels
so the machine can continue running. It is important to be quick and accurate when reloading the labels.
Watch the video and read the step-by-step instructions to complete this training.
</p>
</div>
<div class= "trainingStepList">
<p>
1. Pull off used back paper <br>
2. Find new pack of front & back labels <br>
3. Insert front labels onto the front left roller <br>
4. Insert back labels onto the front right roller <br>
</p>
</div>
<video class="trainingVideo" controls>
<source src="testVid.mp4">
</video>
<!--add video element-->
<!--add step by step instructions-->
<!--need a text header, a step by step instruction list, a video, and an input form for name-->
</div>
</div>
Here is my CSS
.popUpModal{
width: 100%;
height: 100%;
top: 0;
background-color: rgba(0,0,0,0.7);
display: none;
position: fixed;
justify-content: center;
align-items: center;
text-align: center;
}
.popUpContent{
width: 50%;
height: 80%;
padding-bottom: 20px;
background-color: white;
border-radius: 8%;
display: inline-block;
justify-content: center;
vertical-align: center;
position: relative;
font-family: "Source Sans Pro",sans-serif;
}
.close{
position: absolute;
right: 5px;
margin-right: 5%;
font-size: 40px;
transform: rotate(45deg);
font-weight: bold;
cursor: pointer;
}
.trainingPopUpHeader{
margin-top: 4%;
font-size: 40px;
text-decoration: underline;
}
.trainingPopUpDescription{
margin-top: 4%;
margin-left: 10%;
margin-right: 10%;
font-size: 20px;
}
.trainingStepList{
margin-left: 4%;
font-weight:bold;
text-align: left;
font-size: 30px;
}
.trainingVideo{
height: 25%;
border-radius: 5%;
margin-bottom: 3%;
}
Here is my JavaScript, it does not work
var modal = document.getElementsByClassName("popUpModal");
var trainingCard = document.getElementsByClassName("trainingCard");
trainingCard.onclick = function(){
modal.style.display = "flex";
}