I am parsing an existing HTML table on a web page into an array of numbers in order to go to the plot object later. I am learning JavaScript, and it is unclear how I should iterate over data values โโin HTML tags. This is what I came up with:
for (i = 0; i < table.rows.length; i += 1) {
row = table.rows[i];
for (j = 0; j < row.cells.length; j += 1) {
cell = row.cells[j];
coord[j] = Number(cell.innerText);
}
data[i] = coord.slice();
}
I am concerned about the .innerText part. Is this a universal mechanism for iterating over text elements in tags <td>?
source
share