forked from solygambas/html-css-javascript-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
29 lines (26 loc) · 922 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
25
26
27
28
29
const ratings = document.querySelectorAll(".rating");
const ratingsContainer = document.querySelector(".ratings-container");
const sendButton = document.getElementById("send");
const panel = document.getElementById("panel");
let selectedRating = "Satisfied";
const removeActive = () => {
for (let i = 0; i < ratings.length; i++) {
ratings[i].classList.remove("active");
}
};
ratingsContainer.addEventListener("click", (e) => {
if (e.target.parentNode.classList.contains("rating")) {
removeActive();
e.target.parentNode.classList.add("active");
selectedRating = e.target.nextElementSibling.innerHTML;
}
});
sendButton.addEventListener("click", (e) => {
panel.innerHTML = `
<i class="fas fa-heart"></i>
<strong>Thank You!</strong>
<br>
<strong>Feedback: ${selectedRating}</strong>
<p>We'll use your feedback to improve our customer support</p>
`;
});