Created
May 24, 2021 15:15
-
-
Save YasuoFromDeadScream/d97ca3972c3f04d9746256becf116902 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script language="javascript" type="text/javascript"> | |
var Choices = []; | |
// ①問題となる文字列を設定 | |
const mondai = "1 + 1 = ??"; | |
// ②正解となる文字列を設定 | |
const seikai = "2"; | |
// ③選択肢を増やす、7行目を例に行をコピーして張り付ける | |
Choices.push("2"); | |
Choices.push("4"); | |
document.write(" Quiz"),document.write(" <h5>"+mondai+"</h5>");for(let e=0;e<Choices.length;e++)document.write(" <div>"),document.write('\t <input type="radio" name="quizRadio" onchange="checkAnswer()" value="'+Choices[e]+'" >'),document.write("\t <label id="+e+' for="radio">'+Choices[e]+"</label>"),document.write("\t</div>");function checkAnswer(){var e=document.getElementsByName("quizRadio");for(let t=0;t<e.length;t++)if(e[t].checked&&e[t].value==seikai){document.getElementById(t);alert("正解")}} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment