1
was creating a menu that had two buttons, a Description tab and another show tab of the data sheet.
I created a function in javascript that when clicking the button display of an would None and another block.
I did the following:
HTML
<button onclick='funcao("tec","des")'>Descricao</button>
<button onclick='funcao("des","tec")'>Tecnico</button>
<div class="des">
<p>
Isso eh uma descricao
</p>
</div>
<div class="tec">
<p>
isso eh uma ficha tecnica
</p>
</div>
JAVASCRIPT
function funcao(desaparece, aparece){
var desa, apar;
desa = document.getElementsByClassName(desaparece);
apar = document.getElementsByClassName(aparece);
desa.style.display = 'none';
apar.style.display = 'block';
}
but it wasn’t working I researched a little I did another function:
function funcao(desaparece, aparece){
var desa, apar;
desa = document.getElementsByClassName(desaparece);
apar = document.getElementsByClassName(aparece);
for (i = 0; i < desa.length; i++) {
desa[i].style.display = "none";
}
for (i = 0; i < apar.length; i++) {
apar[i].style.display = "block";
}
}
and that worked , but I can not understand why one worked and another not.