-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
76 lines (42 loc) · 1.65 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
let start = document.querySelector(".start");
let opening = document.querySelector(".opening");
let quiz = document.querySelector(".quiz");
let question = document.querySelector(".question");
let answers = document.querySelector(".answers");
let options = document.querySelectorAll(".options");
let optionsCorrect = document.querySelectorAll(".optionsCorrect");
let score = document.querySelector(".js-score");
let end = document.querySelector(".end");
let winner = document.querySelector(".winner");
let done = document.querySelector(".done");
let headers = document.querySelector(".headers");
quiz.style.opacity = 0;
let scoreAdded = score.innerText;
scoreAdded = 0
start.addEventListener("click", function () {
opening.style.display = "none"
quiz.style.opacity = 100;
})
for (let i = 0; i < options.length; i++) {
options[i].addEventListener("click", function (e) {
e.target.style.backgroundColor = "#E87F6C";
})
}
winner.style.opacity = 0;
for (let i = 0; i < optionsCorrect.length; i++) {
optionsCorrect[i].addEventListener("click", function (e) {
e.target.style.backgroundColor = "#4CAF50";
scoreAdded +=10
score.innerText = scoreAdded
if (scoreAdded >= 100) {
end.addEventListener("click", function () {
quiz.style.display = "none"
headers.style.display = "none"
winner.style.opacity = 100;
})
}
})
}
// score applied for right answer only, when anything clicked, move to next slid
//make all right answer the same class to make easier in css
//make all wrong asnwer the same class