Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
How to add a <tr> so that the tasks can be shown 1 after the other in a JS/CSS/HTML To-Do List?

So in a to-do list project, I wrote this:

 <table id="list">
      <tr>
        <span id="task" />
        <input id="inTask" placeholder="Add Task" />
      </tr>
    </table>
    <button id="addTask" type="button" onclick="addTask()">+</button>

Which is supposed to add an Input onclick, and show the previous input value above the input field. Here is the JavaScript function:

  function addTask() {
    let table = document.getElementById("list");
    let input =
      '<tr><span id="task" /><input id="inTask" placeholder="Add Task" /></tr>';

    let task = document.getElementById("inTask").value;

    if (task !== "") {
      document.getElementById("task").innerText = task;
      document.getElementById("list").innerHTML += input;

    }
  }

The problem is that when I add a task, the input field is added, but then when I type a task in the new input field, it show the value of the new input instead of the old, you can try it to understand: https://t3wth8.csb.app And I am out of ideas on how to fix that.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda