I'm trying to get the value of a <a>
that I send to a JavaScript function, but I do not know what's going wrong.
//HTML
<div id="dicaDiv" class="text-center">
<p id="pDica1" style="display: inline;">Dica 1: <span id="mostrarDica1"><a value="dica1" href="javascript:gerarDica(this.value);">mostrar dica</a></span>.</p><br>
<p id="pDica2" style="display: inline;">Dica 2: <span id="MostrarDica2"><a value="dica2" href="javascript:gerarDica(this.value);">mostrar dica</a></span>.</p><br>
</div>
//JS
var dica;
function gerarDica(dica) {
if(dica == "dica1") {
if(randomClasse == 0)
dica = "veículo";
else if(randomClasse == 1)
dica = "animal";
else if(randomClasse == 2)
dica = "cor";
document.getElementById("mostrarDica1").innerHTML = dica;
document.getElementById("botaoDica").style.display = "none";
}
}
The variable randomClasse
is working, the problem is when I try to put this if(dica == "dica1")
.