我正在制作“下一步”按钮以移至此游戏中的下一张抽认卡,但是当我单击该按钮时,什么也没有发生。我不知道我做错了什么。
我在这段代码中使用了很多变量,例如数字变量来说明它是哪个问题和答案。我尝试每次向 number 变量添加一个,以将其更改为下一个问题,但它不起作用。
<div id="flashcard" onclick="flip()"><h1 id="word"></h1></div>
<br>
<button onlick="next()">Next</button>
<script>
var questions;
questions = ['artistic','daring','good','sports-minded','messy','disorganized','studious','funny','impacient','intelligent','neat','patient','lazy','shy','serious','nice','sociable','talented','hardworking','boy','girl','male friend','female friend','I','he','she','very','according to my family'];
var answers = ['artístico, artística','atrevido','bueno, buena','deportista','desordenado, desordenada','estudioso, estudiosa','gracioso, graciosa','impaciente','intelligente','ordenado, ordenada','paciente','perezoso, perezosa','reservado, reservada','serio, seria','simpático, simpática','sociable','talentoso, talentosa','trabajador, trabajadora','el chico','la chica','el amigo','la amiga','yo','él','ella','muy','según mi familia'];
var number = 0;
var answer = answers[number];
var word = questions[number];
var display = document.getElementById('word');
display.innerHTML = word;
function flip(){
if(word == questions[0]){
display.innerHTML = answer;
}
if (word == questions[1]){
display.innerHTML = answer;
}
if (word == questions[2]){
display.innerHTML = answer;
}
if (word == questions[3]){
display.innerHTML = answer;
}
if (word == questions[4]){
display.innerHTML = answer;
}
if (word == questions[5]){
display.innerHTML = answer;
}
if (word == questions[6]){
display.innerHTML = answer;
}
if (word == questions[7]){
display.innerHTML = answer;
}
if (word == questions[8]){
display.innerHTML = answer;
}
if (word == questions[9]){
display.innerHTML = answer;
}
if (word == questions[10]){
display.innerHTML = answer;
}
if (word == questions[11]){
display.innerHTML = answer;
}
if (word == questions[12]){
display.innerHTML = answer;
}
if (word == questions[13]){
display.innerHTML = answer;
}
我想要发生的是当用户单击“下一步”按钮时,它会更改为下一个闪存卡。
茅侃侃
相关分类