0
In my program the player always stays in "player 1". Does anyone know why?
<span id="info_jogador" style="visibility: hidden">Jogador: <span id="jogador">1</span></span>
//script
if (jogador == 1)
{
document.getElementById("b" + pos + "-" + coluna).src = img_blue;
jogador = 2;
name = img_blue;
}
else
{
document.getElementById("b" + pos + "-" + coluna).src = img_red;
jogador = 1;
name = img_red;
}
Have you ever given a console.log() on this 'player'? Checked the type?
– Vinícius
@I don’t know what you meant. But I already gave console.log("hello") for example, and the program is coming to that part, if I made myself aware.
– Gonçalo Sousa
What is this
jogador 1
that you mentioned? Is the player variable? Is some element of the DOM with the internal HTML "player"? From your code you can’t tell what the problem is, try to describe more of what’s going on.– Andre
@user140828 player is like a "label", what varies is only 1 and 2. But at this point the program keeps if only in 1
– Gonçalo Sousa