-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (24 loc) · 880 Bytes
/
app.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 ratingItem = document.querySelectorAll(".rating-item");
const ratingItemArray = Array.prototype.slice.call(ratingItem);
let activeButton = null;
ratingItemArray.forEach((item) => {
item.addEventListener("click", () => {
item.classList.toggle("active");
if (activeButton && activeButton !== item) {
activeButton.classList.remove("active");
}
activeButton = item;
let selectedValue = document.querySelector(".selected-value");
selectedValue.innerHTML = `You selected ${activeButton.innerHTML} out of 5`;
});
});
const button = document.querySelector("button");
button.addEventListener("click", (e) => {
if (!activeButton) {
return;
}
let cardContainer = document.querySelector(".card");
cardContainer.style.display = "none";
let cardThanks = document.querySelector(".card-thanks");
cardThanks.style.display = "block";
});