forked from ITSchool-Web-Heroines/Tema-DOM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
18 lines (16 loc) · 684 Bytes
/
script.js
File metadata and controls
18 lines (16 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
Scrie cod astfel încât să funcționeze interfața:
La apăsarea unui buton (.buttons a):
- Se șterg clasele "active" de la fiecare `.buttons a` și `.tabs article`
- Adaugă clasa "active" la butonul apăsat
- Adaugă clasa "active" la tab-ul identificat prin atributul data-target
*/
const button = document.querySelector(".buttons");
button.addEventListener("click", (event) => {
const item = document.querySelectorAll(".tabs article, .buttons a");
item.forEach((currentValue) => {
currentValue.classList.remove("active");
});
const article = document.querySelector(event.target.dataset.target);
article.classList.add("active");
});