-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (25 loc) · 892 Bytes
/
script.js
File metadata and controls
30 lines (25 loc) · 892 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
28
29
30
const container = document.querySelector(`.container`);
const choices = document.querySelectorAll(`.choice`);
const btn = document.getElementById(`btn`);
const match = [ `Unhappy` , `Neutral` , 'Satisfied'];
choices.forEach(choice => {
choice.addEventListener('click', () => {
choices.forEach(temp => {
temp.classList.remove(`active`);
})
choice.classList.add(`active`);
})
})
btn.addEventListener('click', () => {
let rating =``;
choices.forEach((choice, idx) => {
if(choice.classList.contains(`active`))
rating = match[idx];
})
container.innerHTML = `
<i class="fas fa-heart"></i>
<strong class="greeting">Thank You!</strong>
<p class="feedback">FeedBack : <strong>${rating}</strong></p>
<p class="feedbackPromise">We'll use your feedback to improve our customer support</p>
`;
})