I want to make a single button that changes its name and hides div1
and shows div2
.
The button would have the name div1
when it was showing div1
and the same default 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>