获取已选中checkbox所在行其他列的值

//通过table的id获取已选中checkbox的当前行第n列的值,并组合成字符串返回

function getTDText1(tableId, chkName, n) {

var rows = $(tableId).rows;

var objs = document.getElementsByName(chkName);

var temp = "";

for (var i = 0; i < objs.length; i++) {

if (objs[i].checked) {

var r = objs[i].parentElement.parentElement.rowIndex;

if (temp == "") {

temp = rows[r].cells[n].innerText;

} else {

temp += "," + rows[r].cells[n].innerText;

}

}

}

return temp;

}

 

//通过已选中checkbox的id获取当前行第n列的值,并组合成字符串返回

function getTDText2(chkId, n) {

var temp = "";

var ids = chkId.split(",");

for (var i = 0; i < ids.length; i++) {

var tr = $(ids[i]).parentElement.parentElement;

if (temp == "") {

temp = tr.cells[n].innerText;

} else {

temp += "," + tr.cells[n].innerText;

}

}

return temp;

}

你可能感兴趣的:(获取已选中checkbox所在行其他列的值)