How many of these would I need to make?
For what I am trying to do?
If 1 of the buttons was working in the code using that, I might be able to figure out the rest of it on my own.
This is confusing.
const buttons = document.querySelectorAll("button");
const sections = document.querySelectorAll("section");
buttons.forEach((btn) => {
btn.addEventListener("click", ({ currentTarget }) => {
const hidden = document.querySelectorAll(".hide");
hidden.forEach((ele) => {
ele.classList.remove("hide");
ele.classList.add("show");
});
currentTarget.parentElement.classList.remove("show");
currentTarget.parentElement.classList.add("hide");
});
});
I’m familiar with this:
(function showContainer() {
function hide(el) {
el.classList.add("hide");
}
function show(el) {
el.classList.remove("hide");
}
function exitClickHandler() {
const thewrap = document.querySelector(".container3");
show(thewrap);
const cover = document.querySelector(".container1");
hide(cover);
}
const covers = document.querySelectorAll(".exit, .exitPage2");
covers.forEach(function addCoverListener(cover) {
cover.addEventListener("click", exitClickHandler);
});
})();