Código Javascript
:
Ver originalfunction cambia(a, b){
var id1 = document.getElementById(a);
var id2 = document.getElementById(b);
if(id1.style.display=='block'){
id1.style.display = 'none';
id2.style.display = 'block';
}else{
id1.style.display = 'block';
id2.style.display = 'none';
}
}
//o más simple
function cambia(a, b){
var id1 = document.getElementById(a);
var id2 = document.getElementById(b);
id1.style.display = (id1.style.display == 'block') ? 'none' : 'block';
id2.style.display = (id1.style.display == 'block') ? 'none' : 'block';
}
Código HTML:
Ver original<input type='button' value='Ver / No ver' onclick='cambia("id1", "id2");' /> <div id='id1' style='display:block;'>1
</div> <div id='id2' style='display:none;'>2
</div>
Saludos (: