Compare commits
2 Commits
solucion-e
...
ccabe13670
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccabe13670 | ||
|
|
9f57950a7b |
@@ -1 +1,26 @@
|
|||||||
// Agregar aquí el código javascript
|
// Agregar aquí el código javascript
|
||||||
|
|
||||||
|
/* Ejercicio 1: Saludo personalizado
|
||||||
|
|
||||||
|
Crear una página con un campo de texto y un botón. Al hacer clic en el botón,
|
||||||
|
leer el valor del campo y mostrar en la página el mensaje `"Hola, [nombre]!"`.
|
||||||
|
Si el campo está vacío, mostrar en su lugar `"Por favor, ingresá tu nombre."`. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const boton = document.querySelector("#boton");
|
||||||
|
|
||||||
|
boton.addEventListener("click", (e) => {
|
||||||
|
|
||||||
|
const nombre = document.querySelector("#nombre").value;
|
||||||
|
|
||||||
|
if (nombre.trim() !== "") {
|
||||||
|
|
||||||
|
document.getElementById("saludo").textContent = `Hola, ${nombre}!`;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
document.getElementById("saludo").textContent = "Por favor, ingresa tu nombre"
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
@@ -8,7 +8,9 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Ejercicio 1</h1>
|
<h1>Ejercicio 1</h1>
|
||||||
|
<input type="text" id="nombre" placeholder="Ingresa tu nombre">
|
||||||
|
<p id="saludo"></p>
|
||||||
|
<button type="submit" id="boton">Enviar</button>
|
||||||
<script src="ejercicio1.js"></script>
|
<script src="ejercicio1.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1 +1,32 @@
|
|||||||
// Agregar aquí el código javascript
|
// Agregar aquí el código javascript
|
||||||
|
|
||||||
|
/* Ejercicio 2: Lista de tareas simple
|
||||||
|
|
||||||
|
Crear una página con un campo de texto y un botón "Agregar". Cada vez que se
|
||||||
|
haga clic en el botón, agregar el texto del campo como un nuevo ítem en una
|
||||||
|
lista `<ul>`. Después de agregar el ítem, limpiar el campo.
|
||||||
|
|
||||||
|
Si el campo está vacío al hacer clic, no agregar nada. */
|
||||||
|
|
||||||
|
|
||||||
|
function agregar () {
|
||||||
|
|
||||||
|
const comidaNueva = document.getElementById("comidaNueva").value;
|
||||||
|
|
||||||
|
if (comidaNueva.trim() !== "") {
|
||||||
|
|
||||||
|
const nuevoLi = document.createElement("li");
|
||||||
|
|
||||||
|
nuevoLi.textContent = comidaNueva;
|
||||||
|
|
||||||
|
document.getElementById("lista").appendChild(nuevoLi);
|
||||||
|
|
||||||
|
document.getElementById("comidaNueva").value = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const boton = document.getElementById("botonAgregar")
|
||||||
|
|
||||||
|
boton.addEventListener("click", agregar);
|
||||||
@@ -9,6 +9,18 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>Ejercicio 2</h1>
|
<h1>Ejercicio 2</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Comidas tradicionales de Argentina:</h2>
|
||||||
|
<ul id="lista">
|
||||||
|
<li>Asado</li>
|
||||||
|
<li>Empanadas</li>
|
||||||
|
<li>Locro</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Agregar una comida a la lista</h3>
|
||||||
|
<input type="text" id="comidaNueva" placeholder="Escribí otra comida tradicional">
|
||||||
|
<br>
|
||||||
|
<button id="botonAgregar">Agregar</button>
|
||||||
<script src="ejercicio2.js"></script>
|
<script src="ejercicio2.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user