Solucio html

De wikiserver
Dreceres ràpides: navegació, cerca
<html>
<head>
<title>Problema</title>
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="funciones.js"></script>
</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>

var x;
x=$(document);
x.ready(inicializarEventos);

function inicializarEventos()
{
  var x;
  x=$("#boton1");
  x.click(presionBoton1);
  x=$("#boton2");
  x.click(presionBoton2);
}

function presionBoton1()
{
  var x;
  x=$("#formulario");
  x.html('<form>Ingrese nombre:<input type="text" id="nombre"><br>Ingrese clave:<input type="text" id="clave"><br><input type="submit" value="confirmar"></form>'); 
}
function presionBoton2()
{
  var x;
  x=$("#formulario");
  alert(x.html());
}