I am making a website and there is a subscription page where there are four buttons. I have a circle on the top right of the container containing the button. the circle is made of a ::before element that is always shown there is also a ::after element that I want to toggle when the button is clicked so that it marks for which subscription is the information shown but I can’t think of a way for the ::after element display to be toggled to block with JS.
function openCity(evt, cityName){
var i, tabcontent;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
document.getElementById(cityName).style.display = "block";
}
.tab{
display:flex;
flex-direction: row;
justify-content: space-evenly;
margin-top: 4rem;
}
.tablinks{
all: unset;
background: #111111;
padding: 2rem;
width: 10rem;
border-radius: 10px;
text-align: center;
font-size: 1.5rem;
position: relative;
cursor: pointer;
}
.container{
position: relative
}
.circle{
position: absolute;
top: 10px;
right: 10px;
width: 30px;
height: 30px;
}
.circle::before{
content: '';
position: absolute;
top: 50%;
right: 2.5px;
transform: translate(0%, -50%);
border-radius: 50%;
width: 25px;
height: 25px;
background-color: #e8f1f2;
}
.circle::after{
content: '';
position: absolute;
display: none;
top: 50%;
right: 7.5px;
transform: translate(0%, -50%);
border-radius: 50%;
width: 15px;
height: 15px;
background-color: var(--secondary-color);
}
.tabcontent{
display: none;
}
<div class="tab">
<div class="container">
<button class="tablinks" onclick="openCity(event, '1')">1</button>
<div class="circle"></div>
</div>
<div class="container">
<button class="tablinks" onclick="openCity(event, '3')">3</button>
<div class="circle"></div>
</div>
<div class="container">
<button class="tablinks" onclick="openCity(event, '6')">6</button>
<div class="circle"></div>
</div>
<div class="container">
<button class="tablinks" onclick="openCity(event, '12')">12</button>
<div class="circle"></div>
</div>
</div>
<div class="showplace">
<div id="1" class="tabcontent">1</div>
<div id="3" class="tabcontent">3</div>
<div id="6" class="tabcontent">6</div>
<div id="12" class="tabcontent">12</div>
</div>
