Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Lista de tarefas a fazer
- let tarefas = [
- { descricao: "Recolher o lixo", data: "02/11/2020", feito: false },
- { descricao: "Enviar email", data: "03/11/2020", feito: false },
- { descricao: "Criar página pessoal", data: "31/10/2020", feito: true },
- { descricao: "Ligar para família", data: "02/11/2020", feito: false },
- { descricao: "Tirar identidade nova", data: "09/11/2020", feito: false },
- ];
- // Referencia ao corpo da tabela
- let conteudo = document.getElementById("conteudo");
- console.log(conteudo);
- // Popula a tabela
- for (let i = 0; i < tarefas.length; i++) {
- let tarefa = tarefas[i];
- console.log(tarefa);
- let linha = document.createElement("tr");
- conteudo.appendChild(linha);
- let posicao = document.createElement("th");
- linha.appendChild(posicao);
- posicao.innerText = i + 1;
- let descricao = document.createElement("td");
- linha.appendChild(descricao);
- descricao.innerText = tarefa.descricao;
- let data = document.createElement("td");
- linha.appendChild(data);
- data.innerText = tarefa.data;
- let feito = document.createElement("td");
- linha.appendChild(feito);
- let input = document.createElement("input");
- input.type = "checkbox";
- input.checked = tarefa.feito;
- feito.appendChild(input);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement