javascript Jquery循环遍历表中没有第一行的所有行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19178488/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 14:40:47  来源:igfitidea点击:

Jquery loop through all the rows in a table without first row

javascriptjqueryhtmlhtml-table

提问by dev1234

I need to loop through all rows for a particular table, and I have done it as below. At one point, I need to remove the matching table row. I couldn't figure out how to skip the first row and loop through all others. My code below is looping through all tr's.

我需要遍历特定表的所有行,我已经完成了如下操作。有一次,我需要删除匹配的表格行。我不知道如何跳过第一行并遍历所有其他行。我下面的代码循环遍历所有 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();
        }

回答by DrColossos

$('#tbl_dynamic_call_dates > tbody  > tr').not(":first").  [....]

to get everything BUT the first

得到一切但第一个



$('#tbl_dynamic_call_dates > tbody  > tr:first'). [...]

or

或者

$('#tbl_dynamic_call_dates > tbody  > tr').first(). [...]

to only get the first

只得到第一个

回答by Reinstate Monica Cellio

Change your selector to this...

将您的选择器更改为此...

$('#tbl_dynamic_call_dates > tbody  > tr:not(:first)')

回答by pala?н

You can do this using the :gt() Selectorlike:

您可以使用以下方法执行此操作:gt() Selector

$('#tbl_dynamic_call_dates > tbody  > tr:gt(0)').each(function() {...});

回答by David says reinstate Monica

$('#tbl_dynamic_call_dates > tbody  > tr:gt(0)').each(/*...*/);

Or:

或者:

$('#tbl_dynamic_call_dates > tbody  > tr').first().siblings().each(/*...*/);