-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (53 loc) · 1.62 KB
/
Copy pathscript.js
File metadata and controls
54 lines (53 loc) · 1.62 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
document.addEventListener("DOMContentLoaded", function () {
const faqItems = document.querySelectorAll(".faq-content");
faqItems.forEach(function (item) {
item.addEventListener("click", function () {
const answer = item.querySelector(".hidden-box");
const icon = item.querySelector(".icon");
closeAllAnswers(answer);
toggleAnswer(answer);
toggleIcon(icon, answer);
});
});
function closeAllAnswers(currentAnswer) {
document.querySelectorAll(".hidden-box").forEach(function (box) {
if (box !== currentAnswer) {
box.style.maxHeight = null;
box.classList.remove("active");
const otherIcon = box.closest(".faq-content").querySelector(".icon");
if (otherIcon) {
otherIcon.style.transform = "rotate(0deg)";
}
}
});
}
function toggleAnswer(answer) {
if (answer.classList.contains("active")) {
answer.style.maxHeight = null;
answer.classList.remove("active");
} else {
answer.style.maxHeight = answer.scrollHeight + "px";
answer.classList.add("active");
}
}
function toggleIcon(icon, answer) {
if (icon) {
if (answer.classList.contains("active")) {
icon.style.transform = "rotate(180deg)";
} else {
icon.style.transform = "rotate(0deg)";
}
}
}
});
document.querySelector(".year").textContent = new Date().getFullYear();
/*
document.addEventListener("DOMContentLoaded", function () {
let body = document.body;
body.style.opacity = 0;
body.style.transition = "opacity 1.5s ease-in-out";
setTimeout(() => {
body.style.opacity = 1;
}, 1500);
});
*/