2
I want to view and hide items from a list when the input is clicked. The code works if in css the ul tag has display:block, but not when it’s display:None; which is what I want.
Javascript:
<script>
function fAbreGuias() {
var vGuias = document.getElementById('guias');
if (vGuias.style.display == "block"){ // se vGuias estiver escondido, exiba-o
vGuias.style.display = "none";
}
else{ // se vGuias for exibido, esconda-o
vGuias.style.display = "block";
}
}
</script>
HTML:
<nav id="menu">
<input type="image" src="_imagens/menuesboco.png" onclick="fAbreGuias()"/>
<ul id="guias">
<li>Guia 1</li>
<li>Guia 2</li>
<li>Guia 3</li>
</ul>
</nav>
CSS
ul#guias li {
display: block;
}
The page needs to start with the hidden list, but the code only works if it starts with the list being displayed.
Thank you very much! That was the problem. I just didn’t understand why it worked with the display: block; and not with the display:None;
– Patrick Cruz
So, honestly I don’t understand, it might be something to do with the dial nodes
ul > #guias > li
, something acts there that makes present the behavior.– LeAndrade