Moja Ra Moja Ra - 1 month ago 6
jQuery Question

How do loop through a table to select a specific table cell on each row using jquery?

I am trying to place text in the 6th table cell of each row of my table. But all I am getting is the first row selected:

$('tbody tr:even td:eq(5)').each(function(){
$(this).text('$145');
});


What adjustment do I need to make?

Answer

I think that the following should work:

$('tbody tr').each(
function(){
    $(this).find('td:eq(5)').text('$145');
});

JS Fiddle demo.

Reference:

Comments