Created
May 28, 2015 00:57
-
-
Save Gonzalo2683/aa7c291f09ff33d51270 to your computer and use it in GitHub Desktop.
Practico 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>TODO supply a title</title> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <link rel="stylesheet" href="css/estilos.css"/> | |
| <script src="js/jquery-1.11.3.min.js"></script> | |
| <script src="js/p7.js"></script> | |
| </head> | |
| <body> | |
| <div class="contenedor"> | |
| <h2>1</h2> | |
| Nombre:<input type="text" id="nombre" /><br /> | |
| Apellido:<input type="text" id="apellido" /><br /> | |
| Nacionalidad:<input type="text" id="nacionalidad" /><br /> | |
| <input id="btnIngresar" type="button" value="Ingresar Datos" /> | |
| <div class="divDatos"></div> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(inicio); | |
| function inicio(){ | |
| //1 | |
| $('#btnIngresar').click(agregarDatos); | |
| } | |
| var datos = [ | |
| ]; | |
| var personas = []; | |
| //1 | |
| function agregarDatos(){ | |
| var nombre = $('#nombre').val(); | |
| var apellido = $('#apellido').val(); | |
| var nacionalidad = $('#nacionalidad').val(); | |
| datos.push({ | |
| 'nombre': nombre, | |
| 'apellido': apellido, | |
| 'nacionalidad': nacionalidad | |
| }); | |
| console.log(datos); | |
| //Version Dos | |
| var persona = {}; | |
| persona['nombrecito'] = nombre; | |
| persona['apellidicito'] = apellido; | |
| persona['paisito'] = nacionalidad; | |
| personas.push(persona); //personas[personas.length]= persona | |
| console.log(personas); | |
| //Recorrer un array sin conocer las claves | |
| var clave = ""; | |
| var personita = personas[0]; | |
| for(clave in personita ){ | |
| console.log('Clave: ' + clave + ' valor: ' + personita[clave]); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment