I do not know anything about Javascript . So even being something "simple" to some to me is a seven-headed animal. It is as follows:
In the following code there is a script that I will use that hides and shows the div by clicking on the button
, except that in this script even though I click a thousand times on button
the value inside it does not change! / p>
function Mudarestado(el) {
var display = document.getElementById(el).style.display;
if(display == "none")
document.getElementById(el).style.display = 'block';
else
document.getElementById(el).style.display = 'none';
}
<div id="minhaDiv">Conteudo</div>
<button type="button" onclick="Mudarestado('minhaDiv')">Mostrar / Esconder</button>
Here's what I wanted to do! I would like that when div
was hidden the text shown in button
was "show" , and when div
was the show I would like it to hide >.
While improving the script, I wish it had a fade effect.
If possible I would like this to be done in pure javascript, because I do not use Jquery in my project, so I find it inconvenient to put a 100kb file just because of something relatively "simple"