-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
27 lines (19 loc) · 726 Bytes
/
main.js
File metadata and controls
27 lines (19 loc) · 726 Bytes
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
const questionButton = Array.from(
document.querySelectorAll(".faq__question-button")
);
function toggleDescription(event) {
const pressedBtn = event.target;
const btnId = pressedBtn.getAttribute("aria-controls");
const btnExpand = pressedBtn.getAttribute("aria-expanded");
const description = document.getElementById(btnId);
btnExpand === "false"
? pressedBtn.setAttribute("aria-expanded", true)
: pressedBtn.setAttribute("aria-expanded", false);
description.classList.toggle("show-description");
pressedBtn.classList.toggle("font-weight-bold");
console.log(btnExpand);
console.log(pressedBtn);
}
questionButton.forEach((button) =>
button.addEventListener("click", toggleDescription)
);