-3
Structure of the Progama:
<body>
<div class = 'tabuleiro' onclick = 'clicar()'>
<div id = 'a1' class = 'espaco'></div>
<div id = 'a2' class = 'espaco'></div>
<div id = 'a3' class = 'espaco'></div>
<div id = 'b1' class = 'espaco'></div>
<div id = 'b2' class = 'espaco'></div>
<div id = 'b3' class = 'espaco'></div>
<div id = 'c1' class = 'espaco'></div>
<div id = 'c2' class = 'espaco'></div>
<div id = 'c3' class = 'espaco'></div>
</div>
<input type="button" value="clicar" onclick = 'resultado()'>
<script>
var a1 = document.getElementById('a1').innerHTML
var a2 = document.getElementById('a2').innerHTML
var a3 = document.getElementById('a3').innerHTML
var b1 = document.getElementById('b1').innerHTML
var b2 = document.getElementById('b2').innerHTML
var b3 = document.getElementById('b3').innerHTML
var c1 = document.getElementById('c1').innerHTML
var c2 = document.getElementById('c2').innerHTML
var c3 = document.getElementById('c3').innerHTML
var vitoria = false
function clicar(){
var espaco_selecionado = event.target
espaco_selecionado.innerHTML = 'X'
}
function conferir(){ //*DÚVIDA
if (a1 == 'X' && a2 == 'X' && a3 == 'X'){
window.alert('VITORIA')
}
}
</script>
</body>
The problem is that the program does not identify that the variables a1, a2 and A3, are with the value 'X', even though I have a function (click()) that puts such value in them.
you want to compare the html ( id content ) with the variables ?
– Risk
The html text is copied only and has no text reference. Example:
var t = 2; var c = t; t = 4;
Output:t=4,c=2
– Maury Developer
Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. To better enjoy the site, understand and avoid closures and negativities worth reading the Stack Overflow Survival Guide in English.
– Bacco