3

I am trying to append a td after the end of an existing td. Below is the following code (I am doing it in jqgrid).

$("#list_toppager_center tr:first td:eq(7)").append("<td class='ui-paging-info'>Col/td>");

I see that column gets added, but it gets added below the column I am trying to append to instead of adding beside. Is the above solution the right way to do it?

DG3
  • 4,860
  • 14
  • 48
  • 61

3 Answers3

7

Something like that should help hopefully:

$(function(){
    $("#list_toppager_center tr:first td:last").after("<td class='ui-paging-info'>Col</td>");
}); 
Dharman
  • 26,923
  • 21
  • 73
  • 125
Greg
  • 1,354
  • 10
  • 11
1

You are missing a < on the closing </td>. I also think you want to select the row and append to that; you are adding a cell inside of a cell, which would make invalid HTML.

toby
  • 887
  • 3
  • 10
  • 21
0

Tables have rows each with the same number of columns... You might add the append for each of the other rows (past row 1).

see: jQuery add HTML table column

$("#list_toppager_center tr:first").append("<td class='ui-paging-info'>New Col<td>");<br />
$("#list_toppager_center tr:gt(0)").append("<td> </td>");<br />
Dharman
  • 26,923
  • 21
  • 73
  • 125
John K.
  • 5,340
  • 1
  • 19
  • 20