-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
82 lines (73 loc) · 3.19 KB
/
index.html
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
77
78
79
80
81
82
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap" rel="stylesheet">
<link href="styles.css" rel="stylesheet">
<title>Trivia!</title>
<script>
document.addEventListener("DOMContentLoaded", function() {
// SECTION 1: MULTIPLE CHOICE Q
let incorrect_buttons = document.querySelectorAll('.incorrect');
let correct_buttons = document.querySelectorAll('.correct');
let msg = document.querySelector('#msg');
for (let i = 0; i < incorrect_buttons.length; i++) {
// for (let incorrect_button of incorrect_buttons) {
// console.log(incorrect_buttons[i]);
incorrect_buttons[i].addEventListener('click', function(){
incorrect_buttons[i].style.background = 'red'; // background or backgroundColor works
msg.innerHTML = "INCORRECT";
});
};
correct_buttons[0].addEventListener('click', function(){
correct_buttons[0].style.backgroundColor = "green";
msg.innerHTML = "CORRECT";
});
// SECTION 2: FREE ANSWER Q
let text = document.querySelector('#text');
let submit = document.querySelector('#submit');
let msg1 = document.querySelector('#msg1');
submit.addEventListener('click', function(){
if (text.value == 'emerson')
{
text.style.color = 'green';
msg1.innerHTML = "CORRECT";
}
else
{
text.style.color = 'red';
msg1.innerHTML = "INCORRECT";
}
});
});
</script>
</head>
<body>
<div class="header">
<h1>Trivia!</h1>
</div>
<div class="container">
<div class="section">
<h2>Part 1: Multiple Choice </h2>
<hr>
<h3>What is the most populated city in Texas?</h3>
<button class="incorrect">Dallas</button>
<button class="incorrect">Fort Worth</button>
<button class="incorrect">Austin</button>
<button class="correct">Houston</button>
<button class="incorrect">San Antonio</button>
<button class="incorrect">El Paso</button>
<button class="incorrect">Galveston</button>
<button class="incorrect">Waco</button>
<p id="msg"></p>
</div>
<div class="section">
<h2>Part 2: Free Response</h2>
<hr>
<h3>Which automation company is the greatest in Silicon Hill?</h3>
<input id="text" type="text">
<input id="submit" type="submit" value="Check answer">
<p id="msg1"></p>
</div>
</div>
</body>
</html>