+ 1
Help me!!
function win(userChoice, compChoice) { userScore++; console.log("WIN"); console.log(userScore); userScore_span.innerHTML = userScore; compScore_span.innerHTML = compScore; result_p.innerHTML = ... how can solve this?? it tells me its "an error in syntax innerHTML"
2 Antworten
+ 3
userScore_span is like a variable it's not pointing to DOM that what I can see from this code. You need to point to DOM element that you want to change inner HTML like this.
document.getElementById("id_name_of_element").innerHTML = userScore
+ 1
var userScore_span = document.getElementById("userScore").innerHTML = userScore;
var compScore_span = document.getElementById("compScore").innerHTML = compScore;
its the same result’s