Instead of the background color "light blue" , I want to turn it light green for right and red

Red for wrong. I am using the document.body.style but its not working for some reason. Is there any other way I can get this done?
No description
9 Replies
ἔρως
ἔρως9mo ago
can you host this on codepen or show the html as well as the event handler declaration?
vanshika
vanshika9mo ago
https://github.com/vanshika-poojari/quiz-game here is the github link for the code
GitHub
GitHub - vanshika-poojari/quiz-game
Contribute to vanshika-poojari/quiz-game development by creating an account on GitHub.
ἔρως
ἔρως9mo ago
you have the script included twice and you close the body and the html tags twice
vanshika
vanshika9mo ago
oh, that's just by mistake on Github, I'll remove it its not there in my code
ἔρως
ἔρως9mo ago
preventdefault doesn't exist also, why are you using divs as inputs? and buttons? also, your html needs serious cleaning up <span id = user score> </span> <-- this a span with id user and the attribute score <span id="user-score"></span> <-- this is a span with id user-score (this is what you probably meant) don't throw whitespaces all over, because you will cause serious issues and what you've done is basically a <form> with <input type="radio"> surrounded by a <label> and a <button type="submit"> but you re-created this with divs
vanshika
vanshika9mo ago
okay I'll see to it thanks a lot for your input
ἔρως
ἔρως9mo ago
you're welcome
Zakum
Zakum9mo ago
just adding to what epic said, definitely use the correct HTML elements wherever you can. there are a lot, but it's not only more logical and semantic but also more accessible for people using assistive technology. there are a lot of elements but just memorizing the most commonly used ones is good enough, and remembering that you can find them all on mdn if you need a more niche element. <div> is technically supposed to be a "i got nothing better to put here" fallback-y element so keep that in mind
ἔρως
ἔρως9mo ago
indeed i agree with everything you said also, using the correct html will make things work a lot easily instead of trying to hammer a square peg into a triangle hole to then try on the small round hole, if you have the proper html then everything is a lot easier