![](/img/trans.png)
[英]How to loop through table rows, change class, and do it all with “n” number of rows and knowing the values of the FIRST cell in each row
[英]Jquery loop through all the rows in a table without first row
我需要遍歷特定表的所有行,我已經完成了如下操作。 有一次,我需要刪除匹配的表行。 我無法弄清楚如何跳過第一行並循環遍歷所有其他行。 我的下面的代碼循環遍歷所有tr。
$('#tbl_dynamic_call_dates > tbody > tr').each(
function() {
console.log($(this).find(\'td:first\').text());
if($.inArray($(this).find(\'td:first\').text(),array) == -1){
$(this).remove();
}
$('#tbl_dynamic_call_dates > tbody > tr').not(":first"). [....]
得到一切但是第一個
$('#tbl_dynamic_call_dates > tbody > tr:first'). [...]
要么
$('#tbl_dynamic_call_dates > tbody > tr').first(). [...]
只獲得第一個
將選擇器更改為此...
$('#tbl_dynamic_call_dates > tbody > tr:not(:first)')
您可以使用:gt() Selector
執行此操作,如:
$('#tbl_dynamic_call_dates > tbody > tr:gt(0)').each(function() {...});
$('#tbl_dynamic_call_dates > tbody > tr:gt(0)').each(/*...*/);
要么:
$('#tbl_dynamic_call_dates > tbody > tr').first().siblings().each(/*...*/);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.