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
  • 5,070
  • 17
  • 49
  • 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
  • 30,962
  • 25
  • 85
  • 135
Greg
  • 1,401
  • 11
  • 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
  • 885
  • 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
  • 30,962
  • 25
  • 85
  • 135
John K.
  • 5,426
  • 1
  • 21
  • 20