我试图从表的nth
行获取输入值,但无法获取td值以下的值
我尝试了这个
var Clo_Bal = $(thisid).parent().parent().children('.7').html();
但我无法得到它的值
下面是我的表是如何生成的:
var results = '<div style="overflow:auto;"><table id="myTable" class="table table-bordered table-hover dataTable no-footer">';
results += '<thead><tr><th scope="col"></th><th scope="col" >Sno</th><th scope="col" >Agentid</th><th scope="col">Date</th><th scope="col">AgentName</th><th scope="col">Op_Balance</th><th scope="col">SaleValue</th><th scope="col">PaidAmount</th><th scope="col">ClosingValue</th><th scope="col"></th></tr></thead></tbody>';
var k = 1;
for (var i = 0; i < msg.length; i++) {
results += '<tr><td><input id="btn_poplate" type="button" onclick="getme(this)" name="submit" class="btn btn-primary" value="Update" /></td>';
//k++;
results += '<td scope="row" style="text-align:center;">' + k + '</td>';
results += '<th scope="row" class="1" style="text-align:center;">' + msg[i].AgentId + '</th>';
results += '<td class="2">' + msg[i].inddate + '</td>';
results += '<td class="3">' + msg[i].AgentName + '</td>';
results += '<td class="4">' + msg[i].opp_balance + '</td>';
//results += '<td><input id="txt_OpBal" data-title="Code" style="width:65px;" onkeyup="CLChange(this);" class="4" value="' + msg[i].opp_balance + '"/></td>';
results += '<td><input id="txt_SaleValue" class="5" style="width:65px;" value="' + msg[i].salesvalue + '"/></td>';
results += '<td><input id="txt_PaidAmount" class="6" style="width:65px;" value="' + msg[i].paidamount + '"/></td>';
results += '<td><input id="txt_CloBal" class="7" style="width:65px;" value="' + msg[i].clo_balance + '"/></td>';
results += '<td><input id="txt_Sno" class="8" style="width:65px;display:none;" value="' + msg[i].sno + '"/></td></tr >';
k++;
}
results += '</table></div>';
$("#div_BrandData").html(results);
1条答案
按热度按时间5ssjco0h1#
如果选择nthRow
tr:eq(${nthRow - 1})
选择表体中的第n行,nthRow是行号减1,以考虑从零开始的索引。td:eq(7)
选择所选行中的第8个td元素(索引7)。这假设您要选择该行第8列中的td元素。