Ver Mensaje Individual
  #4 (permalink)  
Antiguo 15/11/2015, 13:49
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Mostrar y ocultar div

@Alexis88
Cita:
display: "none";
prueba con este otro
Cita:
function evento() {

var inst = new variables();

Array.prototype.forEach.call(arguments, function (v, i, arr) {

document.querySelector(arr[i][0]).addEventListener('click', function() {

inst.muestra_oculta(arr[i][1]);

}, false)
})

}


function variables() {

this.cont = 0;
this.sel = null;
}


variables.prototype.muestra_oculta = function(id) {

if (this.sel === id || this.sel == null) {
document.querySelector(id).style.display = (this.cont++ % 2 == 0) ? 'block' : 'none';

} else if (this.sel !== id) {

document.querySelector(id).style.display = 'block';
document.querySelector(this.sel).style.display = 'none';
this.cont = 1;
}

this.sel = id;
}




document.addEventListener('DOMContentLoaded', function() {

evento.apply(null, [['.content-resultados', '#id1'], ['.content-opiniones', '#id2']]);

}, false);



<div class="content-resultados">
Productos
</div>
<div class="content-opiniones">
Comentarios
</div>

<div id="id1" style="display:none;">
Contenido productos...
</div>
<div id="id2" style="display:none;">
Contenido Comentarios...
</div>
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}