3

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.

$('#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();
        }

4 Answers 4

15
$('#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

Sign up to request clarification or add additional context in comments.

Comments

8

Change your selector to this...

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

Comments

4

You can do this using the :gt() Selector like:

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

Comments

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

Or:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.