Ver ❯
Herramientas SEO
Tamaño del resultado:
668 x 574
×
Cambiar Orientacion
Cambiar tema, Oscuro/Luz
<!doctype html> <html lang="es-ES"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Validación con expresión regular y nuevo texto y nuevo texto</title> <script type="text/javascript"> function nuevoTexto() { // Obtiene el div que tiene id="parrafos" var d = document.getElementById("parrafos"); // Crea un nuevo elemento de tipo párrafo var np = document.createElement("p"); // Inserta el texto en el contenido del nuevo párrafo np.textContent = document.getElementById("texto").value; // Añade el párrafo al final de los elementos que contenga el div d.appendChild(np); return false; } </script> </head> <body> <form id="miFormulario" action="" method="get" onsubmit="return nuevoTexto()" > <p> Texto: <input type="text" id="texto" /> <br /> <input type="submit" value="Añade texto" /> </p> </form> <div id="parrafos"> <!-- Inicialmente vacío --> </div> </body> </html>