-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
24 lines (20 loc) · 807 Bytes
/
script.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
let accordionHead = document.querySelectorAll(".accordion-head");
// let activeClass = "accordion-active";
accordionHead.forEach((head) => {
head.addEventListener("click", () => {
let accordionContent = head.nextElementSibling;
console.log(accordionContent);
head.classList.toggle("accordion-active");
if (head.classList.contains("accordion-active")) {
head.style.fontWeight = "700";
// accordionContent.style.display = "block";
accordionContent.style.visibility = "visible";
accordionContent.style.maxHeight = accordionContent.scrollHeight + "px";
} else {
head.style.fontWeight = "400";
// accordionContent.style.display = "none";
accordionContent.style.visibility = "hidden";
accordionContent.style.maxHeight = 0;
}
});
});