質問編集履歴
2
javascript を修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -134,41 +134,45 @@
|
|
134
134
|
|
135
135
|
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
f
|
137
|
+
if(i = 0) {
|
140
|
-
|
138
|
+
|
141
|
-
|
139
|
+
addClass()
|
140
|
+
|
141
|
+
|
142
|
+
|
142
|
-
|
143
|
+
doAll()
|
144
|
+
|
143
|
-
}
|
145
|
+
}
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
146
|
+
|
148
|
-
|
149
|
-
|
147
|
+
|
150
|
-
|
151
|
-
|
148
|
+
|
152
|
-
|
153
|
-
function
|
149
|
+
function doAll () {
|
154
|
-
|
150
|
+
|
155
|
-
let
|
151
|
+
for(let j = 0; j < buttons.length; j++){
|
152
|
+
|
156
|
-
|
153
|
+
buttons[j].addEventListener('click', function() {
|
154
|
+
|
157
|
-
|
155
|
+
buttons[j].classList.add('optionclicked')
|
158
|
-
|
159
|
-
|
160
|
-
|
156
|
+
|
161
|
-
next.addEventListener('click', function() {
|
157
|
+
next.addEventListener('click', function() {
|
162
|
-
|
158
|
+
|
163
|
-
if(answer ===
|
159
|
+
if(answer === buttons[j].value) {
|
164
|
-
|
160
|
+
|
165
|
-
matches += 1
|
161
|
+
matches += 1
|
166
|
-
|
162
|
+
|
167
|
-
}
|
163
|
+
}
|
168
|
-
|
164
|
+
|
165
|
+
|
166
|
+
|
169
|
-
|
167
|
+
removeClass()
|
168
|
+
|
169
|
+
|
170
|
+
|
170
|
-
|
171
|
+
displayNext()
|
172
|
+
|
173
|
+
|
174
|
+
|
171
|
-
|
175
|
+
})
|
172
176
|
|
173
177
|
})
|
174
178
|
|
@@ -176,9 +180,35 @@
|
|
176
180
|
|
177
181
|
|
178
182
|
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
function displayNext () {
|
188
|
+
|
189
|
+
div[i+1].classList.add('pressed')
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
function removeClass () {
|
196
|
+
|
197
|
+
let divget = $docs.getElementsByClassName('pressed')[0]
|
198
|
+
|
199
|
+
divget.classList.remove('pressed')
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
function addClass() {
|
206
|
+
|
179
|
-
|
207
|
+
let ul = $docs.getElementsByClassName('ul')
|
180
|
-
|
208
|
+
|
181
|
-
|
209
|
+
ul[i].classList.add('pressed')
|
210
|
+
|
211
|
+
}
|
182
212
|
|
183
213
|
|
184
214
|
|
@@ -194,6 +224,8 @@
|
|
194
224
|
|
195
225
|
$docs.addEventListener('DOMContentLoaded', getQuestions().then(question_list => displayQuestions(question_list)));
|
196
226
|
|
227
|
+
|
228
|
+
|
197
229
|
```
|
198
230
|
|
199
231
|
|
1
jsonファイルを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -256,6 +256,122 @@
|
|
256
256
|
|
257
257
|
|
258
258
|
|
259
|
+
```
|
260
|
+
|
261
|
+
json
|
262
|
+
|
263
|
+
{
|
264
|
+
|
265
|
+
"questions": [
|
266
|
+
|
267
|
+
{
|
268
|
+
|
269
|
+
"question": "How many chairs are there?",
|
270
|
+
|
271
|
+
"fields": {
|
272
|
+
|
273
|
+
"a": 1,
|
274
|
+
|
275
|
+
"b": 2,
|
276
|
+
|
277
|
+
"c": 3,
|
278
|
+
|
279
|
+
"d": 4
|
280
|
+
|
281
|
+
},
|
282
|
+
|
283
|
+
"answer": 1
|
284
|
+
|
285
|
+
},
|
286
|
+
|
287
|
+
{
|
288
|
+
|
289
|
+
"question": "How many lights are there?",
|
290
|
+
|
291
|
+
"fields": {
|
292
|
+
|
293
|
+
"a": 1,
|
294
|
+
|
295
|
+
"b": 2,
|
296
|
+
|
297
|
+
"c": 3,
|
298
|
+
|
299
|
+
"d": 4
|
300
|
+
|
301
|
+
},
|
302
|
+
|
303
|
+
"answer": 3
|
304
|
+
|
305
|
+
},
|
306
|
+
|
307
|
+
{
|
308
|
+
|
309
|
+
"question": "What is it on the sofa?",
|
310
|
+
|
311
|
+
"fields": {
|
312
|
+
|
313
|
+
"a": "person",
|
314
|
+
|
315
|
+
"b": "stove",
|
316
|
+
|
317
|
+
"c": "cushions",
|
318
|
+
|
319
|
+
"d": "Beats me"
|
320
|
+
|
321
|
+
},
|
322
|
+
|
323
|
+
"answer": "cushions"
|
324
|
+
|
325
|
+
},
|
326
|
+
|
327
|
+
{
|
328
|
+
|
329
|
+
"question": "Where is the light bulb?",
|
330
|
+
|
331
|
+
"fields": {
|
332
|
+
|
333
|
+
"a": "desk",
|
334
|
+
|
335
|
+
"b": "table",
|
336
|
+
|
337
|
+
"c": "ceiling",
|
338
|
+
|
339
|
+
"d": "Beats me"
|
340
|
+
|
341
|
+
},
|
342
|
+
|
343
|
+
"answer": "table"
|
344
|
+
|
345
|
+
},
|
346
|
+
|
347
|
+
{
|
348
|
+
|
349
|
+
"question": "How many questions have you answered?",
|
350
|
+
|
351
|
+
"fields": {
|
352
|
+
|
353
|
+
"a": 1,
|
354
|
+
|
355
|
+
"b": 2,
|
356
|
+
|
357
|
+
"c": 3,
|
358
|
+
|
359
|
+
"d": 4
|
360
|
+
|
361
|
+
},
|
362
|
+
|
363
|
+
"answer": 3
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
]
|
368
|
+
|
369
|
+
}
|
370
|
+
|
371
|
+
```
|
372
|
+
|
373
|
+
|
374
|
+
|
259
375
|
### 試したこと
|
260
376
|
|
261
377
|
for分をwhileにして、iを+1する場所を関数の最後に行うなどをしましたが、
|