let paramAll = [];
let tableObj = document.getElementById("tableData").getElementsByClassName("item_tr"); // 找到需要获取数据的tr行
for (let i = 0; i < tableObj.length; i++) {
let getOnceFeeValueJson = {};
let xh = (i + 1);
let spmc = tableObj[i].cells[1].textContent; // td中文本数据
let spjd = tableObj[i].cells[2].getElementsByClassName("form-control")[0].value; // td中select下拉选中数据value
let spjdname = tableObj[i].cells[2].getElementsByClassName("form-control")[0].options[spjd].text; // td中select下拉选中数据label
let gzd = tableObj[i].cells[3].getElementsByClassName("form-control")[0].value;
let gzdname = tableObj[i].cells[3].getElementsByClassName("form-control")[0].options[gzd].text;
let zl = tableObj[i].cells[4].getElementsByClassName("form-control")[0].value;
let zlname = tableObj[i].cells[4].getElementsByClassName("form-control")[0].options[zl].text;
let spbz = tableObj[i].cells[5].getElementsByTagName("input")[0].value; // td中input输入数据
let ysbz = tableObj[i].cells[6].getElementsByTagName("input")[0].value;
paramAll.push({ xh, spmc, spjdname, gzdname, zlname, spbz, ysbz });
}
HTML使用DOM对象获取Table数据
最新推荐文章于 2024-08-21 20:15:01 发布