Buenas buscaba hacer una página dinámica html usando unas funciones javaScript. Quiero que al yo añadir un texto por pantalla y pulsar el botón de "Ver" me aparezca un texto debajo de este, y luego yo al pulsar de nuevo el botón me desaparezca el texto de nuevo. De momento con lo que tengo el texto me aparece pero al darle yo de nuevo al botón ya no me hace caso a la función javaScript.
Adjunto el código para que veias como me funciona ahora mismo.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<script>
function aparecer() {
var texto = document.getElementById("texto").value;
if (texto === "texto") {
aparecer2();
return true;
}
return false;
}
function aparecer2() {
document.getElementById('oculto').style.visibility = 'visible';
document.getElementById('boton').style.visibility = 'hidden';
document.getElementById('boton2').style.visibility = 'visible';
}
</script>
<br>Este texto se ve siempre
<input type="text" id="texto">
<input type="button" id="boton" style="visibility:visible" onclick="aparecer()" value="Ver texto oculto">
<input type="button" id="boton2" style="visibility:hidden" onclick="aparecer()" value="Ocultar texto">
<div id="oculto" style="visibility:hidden">
Este texto se verá cuando yo quiera
</div>
</body>
</html>