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>
|
||||
<head>
|
||||
<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>
|
||||
<link rel="stylesheet" href="estilo.css">
|
||||
</head>
|
||||
<body>
|
||||
<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>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user