A
Asarus
Where I should call this function?
If I call it in href doesn't work. (I want to make a simple menu)
function MostrarMenu(objeto) {
esta_abierto = document.getElementById(objeto).style.display;
document.getElementById("menu_preguntas").style.display='none';
if (esta_abierto == 'none') {
document.getElementById(objeto).style.display='none';
alert("Estaba cerrado");
}
else {
document.getElementById(objeto).style.display='none' ;
alert("Estaba abierto");
}
}
<li><a href="preguntas.shtml"
nclick="MostrarMenu('menu_preguntas')";> Preguntas</a></li>
<div id="menu_preguntas" style="display:block">
<ul>
<li><a href="preg_html.shtml" title="Preguntas sobre
HTML">HTML</a></li>
<li><a href="preg_css.shtml" title="Preguntas sobre
CSS">CSS</a></li>
<li><a href="preg_javascript.shtml" title="Preguntas sobre
JavaScript">JavaScript</a></li>
<li><a href="preg_php.shtml" title="Preguntas sobre
PHP">PHP</a></li>
</ul>
If I call it in href doesn't work. (I want to make a simple menu)
function MostrarMenu(objeto) {
esta_abierto = document.getElementById(objeto).style.display;
document.getElementById("menu_preguntas").style.display='none';
if (esta_abierto == 'none') {
document.getElementById(objeto).style.display='none';
alert("Estaba cerrado");
}
else {
document.getElementById(objeto).style.display='none' ;
alert("Estaba abierto");
}
}
<li><a href="preguntas.shtml"
nclick="MostrarMenu('menu_preguntas')";> Preguntas</a></li>
<div id="menu_preguntas" style="display:block">
<ul>
<li><a href="preg_html.shtml" title="Preguntas sobre
HTML">HTML</a></li>
<li><a href="preg_css.shtml" title="Preguntas sobre
CSS">CSS</a></li>
<li><a href="preg_javascript.shtml" title="Preguntas sobre
JavaScript">JavaScript</a></li>
<li><a href="preg_php.shtml" title="Preguntas sobre
PHP">PHP</a></li>
</ul>