2
I want to make a single button that changes name and hides the div1
and shows the div2
.
The button would have the name div1
while showing the div1
and the same standard for div2
.
function mostrar_abas(obj) {
document.getElementById('div_aba1').style.display="none";
document.getElementById('div_aba2').style.display="none";
switch (obj.id) {
case 'mostra_aba1':
document.getElementById('div_aba1').style.display="block";
break
case 'mostra_aba2':
document.getElementById('div_aba2').style.display="block";
break
}
}
<a href="#" onclick="mostrar_abas(this);" id="mostra_aba1" >Mostra Aba 1</a> |
<a href="#" onclick="mostrar_abas(this);" id="mostra_aba2" >Mostra Aba 2</a>
<p></p>
<!-- abas -->
<div id="div_aba1" style="display:none;">
Conteúdo da aba 1
</div>
<div id="div_aba2" style="display:none;">
Conteúdo da aba 2
</div>
For a div to already start visible just take off the None?
– João
Yes, just take the:None display from the HTML tab.
– Allan Andrade
Did the above examples work? It worked already getting visible?
– Allan Andrade
Remember that to start visible you have to change the initial name of the button. I made a third option and updated in the reply.
– Allan Andrade
I was doing some tests and everything worked out, I could understand perfectly now, thank you very much for explaining with 3 options, it became clearer the understanding!!
– João