0
I’m trying to make a dropdown menu just by changing the <div's>
with Js.
Is there any way to use just one function()
to change the <div's>
?
The only solution I’ve found is to create a function()
for each <div>
I wish to hide/re-export but the code would be too long.
What I’ve managed so far is to hide and re-experience a single <div>
.
Follows:
Javascript:
function startmenu(){
ex1.style.display = "none";
}
function abrefecha(){
if(ex1.style.display == "none")
{
ex1.style.display = "block";
}
else
{
startmenu();
}
}
HTML:
<body>
<h1>Exercícios JavaScript</h1>
<a href="javaScript:abrefecha()"><h2> Exercício 1 </h2></a>
<div id="ex1" style="display: none;">
</div>
<a href="javaScript:abrefecha()"><h2> Exercício 2 </h2></a>
<div id="ex2" style="display: none;">
</div>
<a href="javaScript:abrefecha()"><h2> Exercício 3 </h2></a>
<div id="ex3" style="display: none;">
</div>
...