summaryrefslogtreecommitdiff
path: root/wk8/pset/trivia/index.html
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-07-05 05:49:04 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-07-05 05:49:04 +0000
commit8e57df2b1ec0cc3d37c37fde52b4f2714ae974b1 (patch)
treebdc067d8ea35376c17d1d81dd884a18769ae54b5 /wk8/pset/trivia/index.html
parent319a4854a7984bfd509607beb10ee2cca90b710c (diff)
Thu, Jul 4, 2024, 10:49 PM -07:00
Diffstat (limited to 'wk8/pset/trivia/index.html')
-rw-r--r--wk8/pset/trivia/index.html18
1 files changed, 15 insertions, 3 deletions
diff --git a/wk8/pset/trivia/index.html b/wk8/pset/trivia/index.html
index b09fba7..ee73a27 100644
--- a/wk8/pset/trivia/index.html
+++ b/wk8/pset/trivia/index.html
@@ -7,8 +7,20 @@
<title>Trivia!</title>
<script>
// TODO: Add code to check answers to questions
- document.querySelectorAll("correct").addEventListener("click", function() {
- document.querySelectorAll("correct").style.backgroundColor = "red";
+ document.addEventListener('DOMContentLoaded', function() {
+ let correct = document.querySelector('.correct');
+ correct.addEventListener('click', function() {
+ correct.style.backgroundColor = 'green';
+ document.querySelector('#feedback1').innerHTML = 'Correct :3';
+ });
+
+ let incorrects = document.querSelectorAll('.incorrect');
+ for (let i = 0; i < incorrects.length; i++) {
+ incorrects[i].addEventListener('click', function() {
+ incorrect.style.backgroundColor = 'red';
+ document.querySelector('#feedback1').innerHTML = 'Incorrect :(';
+ });
+ }
});
</script>
@@ -29,7 +41,7 @@
<button class="incorrect">answer2</button>
<button class="incorrect">answer3</button>
- <p id="feedback"></p>
+ <p id="feedback1"></p>
</div>