Advertisement
campos20

script.js

Nov 2nd, 2020
1,991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Lista de tarefas a fazer
  2. let tarefas = [
  3.   { descricao: "Recolher o lixo", data: "02/11/2020", feito: false },
  4.   { descricao: "Enviar email", data: "03/11/2020", feito: false },
  5.   { descricao: "Criar página pessoal", data: "31/10/2020", feito: true },
  6.   { descricao: "Ligar para família", data: "02/11/2020", feito: false },
  7.   { descricao: "Tirar identidade nova", data: "09/11/2020", feito: false },
  8. ];
  9.  
  10. // Referencia ao corpo da tabela
  11. let conteudo = document.getElementById("conteudo");
  12. console.log(conteudo);
  13.  
  14. // Popula a tabela
  15. for (let i = 0; i < tarefas.length; i++) {
  16.   let tarefa = tarefas[i];
  17.   console.log(tarefa);
  18.  
  19.   let linha = document.createElement("tr");
  20.   conteudo.appendChild(linha);
  21.  
  22.   let posicao = document.createElement("th");
  23.   linha.appendChild(posicao);
  24.   posicao.innerText = i + 1;
  25.  
  26.   let descricao = document.createElement("td");
  27.   linha.appendChild(descricao);
  28.   descricao.innerText = tarefa.descricao;
  29.  
  30.   let data = document.createElement("td");
  31.   linha.appendChild(data);
  32.   data.innerText = tarefa.data;
  33.  
  34.   let feito = document.createElement("td");
  35.   linha.appendChild(feito);
  36.  
  37.   let input = document.createElement("input");
  38.   input.type = "checkbox";
  39.   input.checked = tarefa.feito;
  40.   feito.appendChild(input);
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement