I'm just trying to find out... why do I have to click 2x (instead of just 1 click) until the text appears for the first time? Could you give me some help to fix that? Thanks!
function mudar() {
var x = document.getElementById("texto");
if (x.style.display == "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
.escondido {
display: none;
}
<button onclick=mudar()>EXIBIR E ESCONDER O TEXTO</button>
<p class="escondido" id="texto">Texto para exibir e esconder</p>