c 读取html table,从 HTML 表中读取数据的 JavaScript

您可以使用 HTML Table id 检索您的表格,并对每个单元格值进行如下处理。您需要以整数或浮点数或任何您想应用于单元格值的数字格式将应用转换应用于单元格值。

L1L2L3
M1M2M3

//get the table using the Table id

var mTable = document.getElementById('cTable');

//get the number of rows of the table

var rowLen = mTable.rows.length;

//loop through rows

for (i = 0; i < rowLen; i++){

//gets number of cells of current row

var rowCells = mTable.rows.item(i).cells;

//get the amount of cells of current row

var cellLen = rowCells.length;

//loop through each cell in the current row

for(var j = 0; j < cellLen; j++){

// get your cell info here

var cellVal = rowCells.item(j).innerHTML;

// You can do the appropriate processing of numerical values below.

alert(cellVal);

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值