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?

1
  • What does the rest of the table look like? How many other tds are there? Commented Jan 14, 2011 at 19:26

3 Answers 3

7

Something like that should help hopefully:

$(function(){
    $("#list_toppager_center tr:first td:last").after("<td class='ui-paging-info'>Col</td>");
}); 
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

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 />

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.