Jquery loop through all the rows in a table without first row
17,939
Solution 1
$('#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
Solution 2
Change your selector to this...
$('#tbl_dynamic_call_dates > tbody > tr:not(:first)')
Solution 3
You can do this using the :gt() Selector
like:
$('#tbl_dynamic_call_dates > tbody > tr:gt(0)').each(function() {...});
Solution 4
$('#tbl_dynamic_call_dates > tbody > tr:gt(0)').each(/*...*/);
Or:
$('#tbl_dynamic_call_dates > tbody > tr').first().siblings().each(/*...*/);
Comments
-
dev1234 almost 2 years
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(); }