-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
24 lines (19 loc) · 785 Bytes
/
index.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
const submitBtn = document.getElementById('submit')
const scoreBtn = document.getElementsByClassName('score')
const selectedScore = document.getElementById('voteSpan')
let score
submitBtn.addEventListener('click', () => {
score = document.getElementsByClassName('clicked').length > 0 ?
document.getElementsByClassName('clicked')[0].innerHTML : 0
document.body.classList.add('thankyou-view')
selectedScore.innerHTML = " " + score + " "
})
Array.prototype.forEach.call(scoreBtn, s => {
s.addEventListener('click', event => {
const boxes = document.getElementsByClassName('clicked');
Array.prototype.forEach.call(boxes, box => {
box.classList.remove('clicked');
});
s.classList.toggle('clicked')
})
})