使用Jquery同时遍历多个动态表的行
我不熟悉Jquery。我正在一件一件地学习。我的要求是创建一个动态jquery数据表。因此,我按照以下方式创建: 变量使用Jquery同时遍历多个动态表的行,jquery,Jquery,我不熟悉Jquery。我正在一件一件地学习。我的要求是创建一个动态jquery数据表。因此,我按照以下方式创建: 变量formattedCKEY是一个动态值,我使用它动态生成表id var issueTableId = "issuetable_"+formattedCKEY; var $issuetable = $(" <table id='" + issueTableId + "' class='stripe nowrap' style='position:relative; top
formattedCKEY
是一个动态值,我使用它动态生成表id
var issueTableId = "issuetable_"+formattedCKEY;
var $issuetable = $("
<table id='" + issueTableId + "' class='stripe nowrap' style='position:relative; top:0px; width:95%;'></table>
");
$issuetable.append('
<thead>
').children('thead')
.append('
<tr />
').children('tr')
.append('
<th nowrap>Select</th>
'+
'
<th nowrap>Priority</th>
' +
'
<th nowrap>Issue ID</th>
' +
var $tbody = $issuetable.append('
<tbody />
').children('tbody');
$.each(cases, function () {
$tbody.append('
<tr />
').children('tr:last')
.append('
<td nowrap><input type="checkbox" /> </td>
')
.append('
<td nowrap>' + $(this).find("PRTY").text() + '</td>
')
.append(sourceRow)
.append('
<td nowrap>' + $(this).find("ISSUEID").text() + '</td>
');
});
var issueTableId=“issuetable_uu2;”+formattedCKEY;
变量$issuetable=$(“
");
$issuetable.append('
)。儿童(“thead”)
.append('
)。儿童(‘tr’)
.append('
挑选
'+
'
优先
' +
'
问题ID
' +
变量$tbody=$issuetable.append('
)。儿童(‘tbody’);
$。每个(案例、功能(){
$tbody.append('
)。children('tr:last')
.append('
')
.append('
“+$(this).find(“PRTY”).text()+”
')
.append(源行)
.append('
“+$(this).find(“ISSUEID”).text()+”
');
});
在这里,我需要遍历所有行,并验证是否在任何行中选中了select框,如果选中,则获取该行信息。如果在动态表中选中了所有复选框,则需要获取所有行信息
到目前为止,我已尝试使用以下代码:
//DataTables aplies style and behavior to <table>
var table = $("#" + issueTableId).DataTable({
"scrollY": 315, // inconsistent IE7/other
"scrollX": true,
"searching": false,
"paging": false,
"info": false
});
table.rows().every(function(rowIdx, tableLoop, rowLoop) {
});
//数据表将样式和行为应用于
变量表=$(“#”+issueTableId)。数据表({
“scrollY”:315,//不一致的IE7/其他
“scrollX”:正确,
“搜索”:错误,
“分页”:false,
“信息”:错误
});
table.rows().every(函数(rowIdx、tableLoop、rowLoop){
});
但是不知何故,table.rows().every()
对我来说不起作用。我的目的是遍历新创建的动态表的所有行,并验证这些行是否被选中。
非常感谢您的帮助。请使用jQuery的每个函数,这将迭代每一行
$(".nowrap tr").each(function() {
$(this).find('td').text() // find particular td value or text
// check conditions
});