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

Asked

Viewed 67 times

0

I have a table with several loaded lines, but I need to take information from the first three lines and store it in a variable without using the function click.With this information stored in a variable I will assign to a field that will load the graph, as I do this via script?

  • 1

    You can show the HTML you have?

1 answer

0

I don’t know exactly what you need, but maybe you could start with something like.

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;
}

https://jsfiddle.net/zkgnddsj/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.