Jquery 筛选从X行开始的表格单元格或行
我需要从X行开始的表格中选择一个单元格 我有这个:Jquery 筛选从X行开始的表格单元格或行,jquery,html-table,Jquery,Html Table,我需要从X行开始的表格中选择一个单元格 我有这个: var filas = $("#table tr"); filas.each(function(index){ console.log( $(this).children(':nth-child(2)').html() ); }); 它在我的控制台中打印每一行,但我正在筛选的那一行除外,包括标题 例如: 我只想得到 我该怎么办 您可以使用has选择器 var filas = $("#tabl
var filas = $("#table tr");
filas.each(function(index){
console.log( $(this).children(':nth-child(2)').html() );
});
它在我的控制台中打印每一行,但我正在筛选的那一行除外,包括标题
例如:
我只想得到
我该怎么办 您可以使用has选择器
var filas = $("#table tr:has(td)");
filas.each(function(index){
console.log( $(this).children(':nth-child(2)').html() );
});
最佳结构是将数据行放在
中,将标题行放在
看看这个链接:
1
2
4
5
6
var filas = $("#table tr:has(td)");
filas.each(function(index){
console.log( $(this).children(':nth-child(2)').html() );
});
<table id="table>
<thead>
<tr><th>heading</th></tr>
</thead>
<tbody id="table-body">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
</tbody>
</table>