JS遍历表格获取每行数据及每个单元格数据
/** * 遍历表格获取每行数据及每个单元格数据 * @param tableID 表格ID */ function GetTable(tableID) { var milasUrl = {};//新建对象,用来存储所有数据 var subMilasUrlArr = {};//存储每一行数据 var tableData = {}; $("#" + tableID + " tbody tr").each(function (trindex, tritem) {//遍历每一行 tableData[trindex] = new Array(); $(tritem).find("input").each(function (tdindex, tditem) { tableData[trindex][tdindex] = $(tditem).val();//遍历每一个数据,并存入 subMilasUrlArr[trindex] = tableData[trindex];//将每一行的数据存入 }); }); for (var key in subMilasUrlArr) { milasUrl[key] = subMilasUrlArr[key];//将每一行存入对象 } return milasUrl; }
相关推荐
yangkang 2020-11-09
lbyd0 2020-11-17
sushuanglei 2020-11-12
85477104 2020-11-17
KANSYOUKYOU 2020-11-16
wushengyong 2020-10-28
lizhengjava 2020-11-13
星月情缘 2020-11-13
huangxiaoyun00 2020-11-13
luyong0 2020-11-08
腾讯soso团队 2020-11-06
Apsaravod 2020-11-05
PeterChangyb 2020-11-05
gaobudong 2020-11-04
wwwjun 2020-11-02
gyunwh 2020-11-02
EchoYY 2020-10-31
dingyahui 2020-10-30