From 32ce9173c2a1e9619b519c14a3e07f42f9ed2efb Mon Sep 17 00:00:00 2001 From: SkyEye_FAST Date: Fri, 12 Jul 2024 02:44:45 +0800 Subject: [PATCH] Try to fix #8 --- static/js/quiz.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/static/js/quiz.js b/static/js/quiz.js index 781b8b6..2784418 100644 --- a/static/js/quiz.js +++ b/static/js/quiz.js @@ -20,11 +20,11 @@ $(document).ready(function () { $("#sourceText").text(question.source); $("#keyText").text(currentKey); + $("#inputBox").val("").attr("maxlength", translationLength); + createBoxes(translationLength); + $("#info").fadeIn(fadeDuration); }); - - $("#inputBox").val("").attr("maxlength", translationLength); - createBoxes(translationLength); } // 创建相应长度的 box @@ -91,7 +91,10 @@ $(document).ready(function () { const correctAnswer = questions[currentKey].translation; if (input === correctAnswer) { - $(".box").css("background-color", "#79b851"); + for (let i = 0; i < correctAnswer.length; i++) { + const box = $("#box" + (i + 1)); + box.css("background-color", "#79b851"); + } if (currentQuestionIndex === questionKeys.length - 1) { setTimeout(showSummary, delayBetweenQuestions);