I am in the process of creating a quiz that resembles the popular BuzzFeed quizzes such as THIS ONE. Although I have mapped out the logic and have an idea of how to code it to function similarly to the one provided in the link, I am encountering issues with the button states.
You can view a sample of my code on this fiddle: sample quiz
$(document).ready(function () {
$('#btn1, #a1').click(function () {
$('#a1').removeClass("fadeout");
$('#a1').addClass("highlight");
$('#a2').removeClass("highlight");
$('#a3').removeClass("highlight");
$('#a4').removeClass("highlight");
$('#a5').removeClass("highlight");
$('#a6').removeClass("highlight");
$('#a2').addClass("fadeout");
$('#a3').addClass("fadeout");
$('#a4').addClass("fadeout");
$('#a5').addClass("fadeout");
$('#a6').addClass("fadeout");
btn1.checked = "true";
btn2.checked = "";
btn3.checked = "";
btn4.checked = "";
btn5.checked = "";
btn6.checked = "";
window.alert(document.write(getElementById("btn1").value));
While coding for a single question, implementing effects like changing color on hover, reducing opacity of unselected choices, and turning selected choice blue is not challenging. However, when expanding to multiple questions, I realized using addClass and removeClass for each choice across all questions would be impractical from a coding perspective.
Are there more efficient methods to address this issue?