-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrating-component.js
23 lines (20 loc) · 950 Bytes
/
rating-component.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const containerOne = document.querySelector(".container-one");
const containerTwo = document.querySelector(".container-two");
const submitButton = document.querySelector(".submit-button");
const thankyou = document.querySelector(".rating-selection");
const ratingValues = document.getElementsByClassName("selected-rating");
for (let i = 0; i < ratingValues.length; i++) {
const ratingValue = ratingValues[i];
ratingValue.addEventListener("click", function () {
thankyou.textContent = `You selected ${ratingValue.innerText} out of 5`;
// add orange background color when rating selected
ratingValue.style.backgroundColor = "orange";
});
//submit clicked: containerOne hidden, containerTwo displayed
submitButton.addEventListener("click", function () {
// display-none added to rating box
containerOne.style.display = "none";
//display-none removed from message box
containerTwo.style.display = "flex";
});
}