-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
39 lines (35 loc) · 1.05 KB
/
Copy pathscript.js
File metadata and controls
39 lines (35 loc) · 1.05 KB
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
31
32
33
34
35
36
37
38
39
const frontPage = document.querySelector('.front-page')
const btn = document.getElementById('btn')
const rate = document.querySelectorAll('.rate')
const thankYou = document.querySelector('.thank-you')
let ratingValue = ''
rate.forEach((rating) => {
rating.addEventListener('click', (e) => {
removeActive()
ratingValue = e.target.innerText
rating.classList.add('active')
})
})
btn.addEventListener('click', () => {
if (ratingValue !== '') {
frontPage.style.display = 'none'
thankYou.classList.add('active')
thankYou.innerHTML += `
<div class="status">
<small> You selected ${ratingValue} out of 5</small>
</div>
<div class="thank-you-message">
<h1>Thank you!</h1>
<p>
We appreciate you taking the time to give a rating. If you ever need
more support, don’t hesitate to get in touch!
</p>
</div>
`
}
})
function removeActive() {
rate.forEach((rating) => {
rating.classList.remove('active')
})
}