get value of table column js code example
Example: get data from column in table js
function getDataFromColumn(table_id, col) {
var tab = document.getElementById(table_id);
var n = tab.rows.length;
var i, s = null, tr, td;
var ss = '';
if (col < 0) {
return null;
}
for (i = 1; i < n; i++) {
tr = tab.rows[i];
if (tr.cells.length > col) {
td = tr.cells[col];
ss += ' ' + td.innerText + ',';
}
}
return ss;
}
var txt =getDataFromColumn('table_ID', 5);