How to get data dynamically in a table? I am not able to put my attempt as I don't know what to do. Please do not consider the given example:
<div id = "tbScore">
<table border="1" style="width:500px">
<tr>
<td>Jill</td>
<td>Smith</td>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
This is how you would get the row data of a table with the id of "myTable":
var table = document.getElementById('myTable');
var rowLength = table.rows.length;
for (i = 0; i < rowLength; i++){
var cells = table.rows.item(i).cells;
var cellLength = cells.length;
for(var j = 0; j < cellLength; j++){
var cellVal = cells.item(j).innerHTML;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.