
previous

page 5
next
Dealing with the player's click
Here's my klick function:
klick() in functions.js
function klick(el) {
var el_answer=document.getElementById(g_answer_id);
el_answer.style.backgroundColor='palegreen';
var id=el.id;
if (id!=g_answer_id) {
el.style.backgroundColor='red';
}
}
var el_answer=document.getElementById(g_answer_id);
el_answer.style.backgroundColor='palegreen';
var id=el.id;
if (id!=g_answer_id) {
el.style.backgroundColor='red';
}
}
Check that this works ok.
Before moving on to multiple questions, we'll need a function to reset the background colours. Here's mine:
clear() in functions.js
function clear() {
for (var i=0;i<5;i++) {
var el=document.getElementById(i);
el.style.backgroundColor='beige';
}
}
for (var i=0;i<5;i++) {
var el=document.getElementById(i);
el.style.backgroundColor='beige';
}
}
previous
next