-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (31 loc) · 931 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$(function () {
$("#nav a").click(function () {
$(this).parent().addClass("active").siblings().removeClass("active");
});
});
const onglets = document.querySelectorAll(".onglets");
const contenu = document.querySelectorAll(".contenu");
let index = 0;
onglets.forEach((onglet) => {
onglet.addEventListener("click", () => {
if (onglet.classList.contains("active")) {
return;
} else {
onglet.classList.add("active");
}
index = onglet.getAttribute("data-anim");
console.log(index);
for (i = 0; i < onglets.length; i++) {
if (onglets[i].getAttribute("data-anim") != index) {
onglets[i].classList.remove("active");
}
}
for (j = 0; j < contenu.length; j++) {
if (contenu[j].getAttribute("data-anim") == index) {
contenu[j].classList.add("activeContenu");
} else {
contenu[j].classList.remove("activeContenu");
}
}
});
});