forked from marquez.juan/clase-10-ejercicios-de-repaso
ejercicio 2: lista de tareas simples
This commit is contained in:
@@ -1 +1,16 @@
|
|||||||
// Agregar aquí el código javascript
|
const tareaInput = document.getElementById('tarea');
|
||||||
|
const agregarBtn = document.getElementById('agregar');
|
||||||
|
const listaTareas = document.getElementById('lista-tareas');
|
||||||
|
|
||||||
|
agregarBtn.addEventListener('click', () => {
|
||||||
|
const tarea = tareaInput.value.trim();
|
||||||
|
|
||||||
|
if (tarea === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const li = document.createElement('li');
|
||||||
|
li.textContent = tarea;
|
||||||
|
listaTareas.appendChild(li);
|
||||||
|
tareaInput.value = '';
|
||||||
|
});
|
||||||
|
|||||||
@@ -2,13 +2,19 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Ejercicio 2</title>
|
<title>Ejercicio 2</title>
|
||||||
<link rel="stylesheet" href="estilo.css">
|
<link rel="stylesheet" href="estilo.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Ejercicio 2</h1>
|
<h1>Ejercicio 2</h1>
|
||||||
|
|
||||||
|
<label for="tarea">Nueva tarea:</label>
|
||||||
|
<input id="tarea" type="text" placeholder="Escribí una tarea">
|
||||||
|
<button id="agregar">Agregar</button>
|
||||||
|
|
||||||
|
<ul id="lista-tareas"></ul>
|
||||||
|
|
||||||
<script src="ejercicio2.js"></script>
|
<script src="ejercicio2.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user