-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
20 lines (18 loc) · 772 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const buttons = document.querySelectorAll(".card-buttons button");
const sections = document.querySelectorAll(".card-section");
const card = document.querySelector(".card");
const handleButtonClick = (e) => {
const targetSection = e.target.getAttribute("data-section");
const section = document.querySelector(targetSection);
targetSection !== "#about"
? card.classList.add("is-active")
: card.classList.remove("is-active");
card.setAttribute("data-state", targetSection);
sections.forEach((s) => s.classList.remove("is-active"));
buttons.forEach((b) => b.classList.remove("is-active"));
e.target.classList.add("is-active");
section.classList.add("is-active");
};
buttons.forEach((btn) => {
btn.addEventListener("click", handleButtonClick);
});