How do I get information from the first three rows of a table?

0

I have a table with several lines loaded, however I need to get information from the first three lines and store in a variable without having to use the click function. With this information stored in a variable I will assign to a field that will load the graphic, how do I do this via script?

    
asked by anonymous 17.06.2017 / 19:06

1 answer

0

I do not know exactly what you need, but maybe you can start with something like that.

function le_tabela(linhas){
  var tabela = $("#tabela").find("tr");
  var matriz = new Array(linhas);
  for(var i=0;i<linhas;i++){
    var linha_tabela = tabela[i].childNodes;
    var tamanho = linha_tabela.length;
    var linha = new Array(tamanho);
    for(var j=0;j<tamanho;j++){
        linha[j] = linha_tabela[j].innerText;
    }
    matriz[i] = linha;
  }
    return matriz;
}

link

    
18.06.2017 / 00:48