To get all data from tables into an array in js?

On the page there are 3 tables
5c9b79b68d5e7853499886.png
They have this structure
<table class="table">
the <tr>
<td></td>
...
</tr>
the <tr>
<td></td>
...
</tr>
...
</table >

How to use js to collect data in this array?
5c9b7b3466414579773395.png
March 19th 20 at 08:51
4 answers
March 19th 20 at 08:53
Solution
Three levels of cycles:
  1. Cycle beroperasi table
  2. The loop iterates over the rows in each table
  3. Cycle through cells in each row

And write all the data into a variable
March 19th 20 at 08:55
Solution
March 19th 20 at 08:57
Solution
Using the DOM and methods of сhildNodes.
https://developer.mozilla.org/ru/docs/Web/API/Node...
March 19th 20 at 08:59
Solution
Solution:
var TableList = new Array();
 var table = document.getElementsByClassName("table");
 for(var i=0;i<table.length;i++){
 var tr = table.item(i).getElementsByTagName("tr");
 TableList['table_'+i] = new Array()
 for(var j=0;j<tr.length;j++) {
 var td = tr.item(j).getElementsByTagName("td");
 TableList['table_'+i]['tr_'+j] = new Array()
 for(var f=0;f<td.length;f++) {
 TableList['table_'+i]['tr_'+j][f] = td.item(f).innerText;
}

}
 console.log(TableList)

Find more questions by tags JavaScript