转自:https://www.cnblogs.com/henuyuxiang/p/6647985.html
1 function GetInfoFromTable(tableid) { 2 var tableInfo = ""; 3 var tableObj = document.getElementById(tableid); 4 for (var i = 0; i < tableObj.rows.length; i++) { //遍历Table的所有Row 5 for (var j = 0; j < tableObj.rows[i].cells.length; j++) { //遍历Row中的每一列 6 tableInfo += tableObj.rows[i].cells[j].innerText; //获取Table中单元格的内容 7 tableInfo += " "; 8 } 9 tableInfo += " "; 10 } 11 return tableInfo; 12 }