diff --git a/kadai04.js b/kadai04.js index b2dedf1..ec635c6 100644 --- a/kadai04.js +++ b/kadai04.js @@ -1,6 +1,6 @@ function CountDown() { var count = 4, tmID, infobox = document.getElementById("start"), fin = document.getElementById("fin"), are = document.querySelectorAll("div"); - //const num = Math.floor(Math.ramdom()*10+1); + num = Math.floor(Math.ramdom()*10+1); function countDown() { if (--count == 0) { infobox.innerHTML = "時間切れ"; @@ -13,7 +13,7 @@ function startCountDown() { tmID = setTimeout(countDown, 1000); infobox.removeEventListener("click", startCountDown, false); - are[Math.floor(Math.ramdom()*10+1)].addEventListener("click", stopCountDown, false); + are[num].addEventListener("click", stopCountDown, false); } function stopCountDown() { if (count >= 0){ @@ -21,8 +21,8 @@ infobox.innerHTML = "成功"; } fin.innerHTML = "終了"; - are[Math.floor(Math.ramdom()*10+1)].innerHTML = "正解"; - are[Math.floor(Math.ramdom()*10+1)].removeEventListener("click", stopCountDown, false); + are[num].innerHTML = "正解"; + are[num].removeEventListener("click", stopCountDown, false); } infobox.addEventListener("click", startCountDown, false); };