Apologies for the vague title, I'm struggling to convey my issue clearly. I've tried looking through similar posts but couldn't find a solution that fits my needs.
Here's what I'm attempting to achieve:
I want to create an array containing elements from the DOM like this:
var boxes = ["box1", "box2", "box3"]
Additionally, I need an array of popups with display:none
var popups = ["pop1", "pop2", "pop3"]
The goal is to click on boxes[i] and have it open popups[i].
My question is how do I capture the [i] event so I can correctly link it to open the corresponding popup?
Although I haven't included code here, you can refer to this template as guidance:
var boxes = document.getElementsByClassName("box");
var popupss = document.getElementsByClassName("pop");
.wrapper {
display: flex;
justify-content:space-between;
}
.box {
cursor:pointer;
display:flex;
justify-content:center;
align-items:center;
background-color: #FC543A;
padding: 50px;
border-radius: 3px;
}
.wrapper2 {
display:flex;
justify-content:center;
background-color: rgba(0,0,0,0.4);
position:fixed;
height:100%;
width:100%;
z-index:2;
overflow:auto;
}
.pop {
margin-top:6em;
background-color:white;
height: 50px;
width: 80%;
display:none;
justify-content:center;
align-items:center;
}
.hide {
display:none;
}
.show {
display:flex;
}
<div class="wrapper">
<div id="box1" class="box">Box1</div>
<div id="box2" class="box">Box2</div>
<div id="box3" class="box">Box3</div>
</div>
<div class="wrapper2">
<div class="pop" id="pop1">
Pop1!
</div>
<div class="pop" id="pop2">
Pop2!
</div>
<div class="pop" id="pop3">
Pop3!
</div>
</div>
Thank you!