mostrar texto al hacer click
Como puedo hacer que, en hacer click a un texto se muestre otro texto que antes quedaba oculto y al volver a pulsar vuelva a esconderse?
Ejemplo:
Antes de clickar:
[+] Mostrar más
Después de clickar:
[-] Ocultar
texto, texto, texto
texto, texto, texto
texto, texto, texto
Gracias.
Ejemplo:
Antes de clickar:
[+] Mostrar más
Después de clickar:
[-] Ocultar
texto, texto, texto
texto, texto, texto
texto, texto, texto
Gracias.
Prueba con esto, espero que te sirva,
Saludos,
8<----------------------------------------------------
<html>
<head>
<title>Prueba</title>
<script>
function mostrar() {
document.getElementById("capa1").style.visibility = "hidden";
document.getElementById("capa2").style.visibility = "visible";
}
function ocultar() {
document.getElementById("capa1").style.visibility = "visible";
document.getElementById("capa2").style.visibility = "hidden";
}
</script>
</head>
<body>
<form name="miFormulario" action="">
<hr>
<br><br>
<span id="capa1" style="visibility:visible">
<a href="javascript:void(0)" onclick="mostrar();">[+] Mostrar</a>
</span><br>
<span id="capa2" style="visibility:hidden">
<a href="javascript:void(0)" onclick="ocultar();">[-] Ocultar</a>
<br>
texto, texto, texto
texto, texto, texto
texto, texto, texto
</span>
</form>
</body>
</html>
Saludos,
8<----------------------------------------------------
<html>
<head>
<title>Prueba</title>
<script>
function mostrar() {
document.getElementById("capa1").style.visibility = "hidden";
document.getElementById("capa2").style.visibility = "visible";
}
function ocultar() {
document.getElementById("capa1").style.visibility = "visible";
document.getElementById("capa2").style.visibility = "hidden";
}
</script>
</head>
<body>
<form name="miFormulario" action="">
<hr>
<br><br>
<span id="capa1" style="visibility:visible">
<a href="javascript:void(0)" onclick="mostrar();">[+] Mostrar</a>
</span><br>
<span id="capa2" style="visibility:hidden">
<a href="javascript:void(0)" onclick="ocultar();">[-] Ocultar</a>
<br>
texto, texto, texto
texto, texto, texto
texto, texto, texto
</span>
</form>
</body>
</html>
