-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (25 loc) · 941 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
const toggles = document.querySelectorAll(".toggle");
const contentDivs = document.querySelectorAll(".content");
const icons = document.querySelectorAll(".toggle img");
toggles.forEach((toggle, i) => {
toggle.addEventListener("click", () => {
const currentContentDiv = contentDivs[i];
const currentIcon = icons[i];
if (parseInt(currentContentDiv.style.height) !== currentContentDiv.scrollHeight) {
currentContentDiv.style.height = currentContentDiv.scrollHeight + "px";
toggle.style.color = "#0084e9";
currentIcon.src = "Asset/minus.svg";
} else {
currentContentDiv.style.height = "0px";
toggle.style.color = "#111130";
currentIcon.src = "Asset/plus.svg";
}
contentDivs.forEach((contentDiv, j) => {
if (j !== i) {
contentDiv.style.height = "0px";
toggles[j].style.color = "#111130";
icons[j].src = "Asset/plus.svg";
}
});
});
});