hi guys i have this code s of tabbed component that most of you familiar with . the problem is that when i click on certain tab i want to other tabs get hidden
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.container {
display: flex;
flex-direction: column;
width: 100%;
height: 100vh;
align-items: center;
justify-content: center;
}
.upContainer {
display: flex;
}
.tab {
width: 100px;
height: 70px;
background-color: aqua;
cursor: pointer;
text-align: center;
margin: 0px 10px;
}
.content {
width: 300px;
height: 100px;
margin-top: 10px;
text-align: center;
background-color: black;
color: aliceblue;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div class="container">
<div class="upContainer">
<div class="tab1 tab">tab1</div>
<div class="tab2 tab">tab2</div>
<div class="tab3 tab">tab3</div>
</div>
<div class="downContainer">
<div class="content__tab1 content">content1</div>
<div class="content__tab2 content hidden">content2</div>
<div class="content__tab3 content hidden">content3</div>
</div>
</div>
<script>
const tab = document.querySelectorAll(".tab");
const tabContainer = document.querySelector(".upContainer");
tabContainer.addEventListener("click", function (e) {
const clicked = e.target.closest(".tab").textContent;
document
.querySelector(`.content__${clicked}`)
.classList.remove("hidden");
});
</script>
</body>
</html>
hi guys i have this code s of tabbed component that most of you familiar with . the problem is that when i click on certain tab i want to other tabs get hidden