![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
19/07/2011, 05:51
|
| | Fecha de Ingreso: diciembre-2010
Mensajes: 47
Antigüedad: 14 años, 2 meses Puntos: 0 | |
Intercambiar divs javascript Buenas estoy intentando hacer que cuando clickes en un enlace aparezca un div y cuando clickes en otro desaparezca el que habia anterior mente y aparezca el div correspondiente a ese enlace pero no me funciona.. tambien me gustaria que al principio de la pagina estuvieran vacios. a ver si alguien me puede ayudar Un saludo
html>
<head>
<title>Muestra oculta</title>
<script language="JavaScript">
function muestra(id){
ocultar('c1');
ocultar('c1');
var el = document.getElementById(id);
el.style.display ='block';
}
}
function ocultar(id){
var el = document.getElementById(id);
el.style.display ='none';
}
window.onload = function (){/*oculta los divs al principio*/
ocultar('c1');
ocultar('c2');
}
</script>
</head>
<body>
<p><a href="#" onclick="mostrar('c1')" title="">Mostrar</a></p>
<p><a href="#" onclick="mostrar('c2')" title="">Mostrar</a></p>
<div id="c1">
<p>contenido 1</p>
</div>
<div id="c2">
<p>contenido 2</p>
</div>
</body>
</html> |