I've set up a webpage with multiple cards displayed on it. My goal is to have a pop-up window appear when a user clicks on each card. Initially, I just want to ensure the basic functionality of the pop-up, even if the content remains the same. Although I managed to get the JavaScript code working using getElementById for a single card, this method won't suffice as there are multiple distinct cards involved here. Can someone assist me in getting this JavaScript feature to work as intended?
Below is my HTML:
<div class="cardContainer">
<div class="trainingCard">
<div class="cardText">
<h1>How to fill out a time card</h1>
<p> To learn how to fill out a time card, click this card to access 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 how to replace the labels in a labeler machine, click this card to access 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>
Given below 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%;
}
Lastly, check out my JavaScript function which needs fixing:
var modal = document.getElementsByClassName("popUpModal");
var trainingCard = document.getElementsByClassName("trainingCard");
trainingCard.onclick = function(){
modal.style.display = "flex";
}