1
I saw an example of comparison and I was in doubt of the reason for the operation.
In the comparison below, he removes the text and <button>
and compares in if
for verification, whether it is true or false, but it never enters the true, even using the ===
to compare.
Apparently, when it comes to taking the value he is "converting" the ˅
and can’t make the comparison.
function trocar(){
valor = document.getElementById('btnTrocar').innerHTML;
console.log(valor);
if(valor == "Imagem ˅"){
document.getElementById("btnTrocar").innerHTML = "Imagem ˂";
alert("Texto 1");
}
else{
document.getElementById("btnTrocar").innerHTML = "Imagem ˅";
alert("Texto 2");
}
}
<button onclick="trocar()" id="btnTrocar">Imagem ˅</button>
If there is such a "conversion":
- what her reason is?
- why it does not treat as a "normal text"?
- has some way to get this text from the button without changing anything?