2
I found a code in one of the questions of the forum, follows:
    function criarTabela(conteudo) {
  var tabela = document.createElement("table");
  var thead = document.createElement("thead");
  var tbody=document.createElement("tbody");
  var thd=function(i){return (i==0)?"th":"td";};
  for (var i=0;i<conteudo.length;i++) {
    var tr = document.createElement("tr");
    for(var o=0;o<conteudo[i].length;o++){
      var t = document.createElement(thd(i));
      var texto=document.createTextNode(conteudo[i][o]);
      t.appendChild(texto);
      tr.appendChild(t);
    }
    (i==0)?thead.appendChild(tr):tbody.appendChild(tr);
  }
  tabela.appendChild(thead);
  tabela.appendChild(tbody);
  return tabela;
}
document.getElementById("tabela").appendChild(criarTabela([
  ["id", "nome",     "idade"],
  [1,    "matheus",  16],
  [2,    "cristian", 16],
  [3,    "pedro",    10],
  [4,    "henrique", 10]
]));
He’s from the member Matheus Cristian and I have a question about it. Would it be possible for one of the columns of the matrix to contain checkboxs? For example:
<input data-index="0" type="checkbox" name="name" value="John" >
I await and thank you.
thank you very much! Solved my problem ;D had never messed with js, need to study more rs
– Pedro Henrique Calixto
If you are starting now recommend reading the excellent article on MDN Introduction to the DOM to learn how to manipulate the HTML document with Javascript.
– rodorgas
was worth ;D I will read the/
– Pedro Henrique Calixto
If my answer was helpful don’t forget to vote in favor and accept it as correct :)
– rodorgas