[英]I want to change this to what is written in the array every time a next question button is pushed
So I have 4 areas in the HTML: Questions, Notes, Button1, Button2.所以我在 HTML 中有 4 个区域:问题、注释、Button1、Button2。 I have an Object with values for each in their own arrays:
我有一个对象,每个对象在自己的数组中都有值:
var list = {
1: ['This is question 1', 'These are notes 1', 'this is answer 1A', 'this is answer 1B'],
2: ['This is question 2', 'These are notes 2', 'this is answer 2A', 'this is answer 2B']
};
When I click the next question button, I want the values to change to the next line of the object Here is my function:当我单击下一个问题按钮时,我希望将值更改为对象的下一行 这是我的函数:
var i = 0;
function nextQuestion() {
i += 1;
document.getElementById('question').innerHTML = list.i[0];
document.getElementById('notes').innerHTML = list.i[1];
document.getElementById('btn1').value = list.i[2];
document.getElementById('btn2').value = list.i[3];
}
I know that I'm close, but I'm a beginner and don't know what I need to do here.我知道我很接近,但我是初学者,不知道我需要在这里做什么。
MAYBE A FOR LOOP???可能是一个 FOR 循环???
Thanks谢谢
Change list.i[0];
更改
list.i[0];
to list[i][0];
list[i][0];
and it should work.它应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.