Solucio modificar formulari

De wikiserver
Dreceres ràpides: navegació, cerca
<!DOCTYPE HTML> 
<html> 
<head> 
  <meta charset="utf-8"> 
    <link rel="stylesheet" href="css/estilos1.css"> 
    <script src="js/jquery-1.5.1.min.js" ></script>  
    <script src="js/fichero4_html.js" ></script>  
  <title>Ejercicio4_html</title> 
</head> 
<body> 
  <input type="button" id="boton1" value="Mostrar formulario"> 
  <input type="button" id="boton2" value="Mostrar elementos html del formulario"><br> 
  <div id="formulario"> 
  </div> 
</body> 
</html> 




//Fichero JavaScript 
$(document).ready(inicializarEventos); 
 
function inicializarEventos(){ 
  $("#boton1").click(presionBoton1); 
    $("#boton2").click(presionBoton2);} 
 
function presionBoton1(){ 
  var x; 
  x=$("#formulario"); 
  x.html("<form>Ingrese nombre:<input type='text' id='nombre'> <br>Introduzca clave:<input type='text' id='clave'>  <br> <input type='submit' value='confirmar'></form>"); } 
 
function presionBoton2(){ 
  $("#formulario"). alert (x.html()); 
}