tags:

views:

639

answers:

2

How to add column on all rows (including header row) using jquery. The added column will be the first column.

A: 

This should do it:

$("tr:first").append("th");
$("tr:not(:first)").append("td");
Andy Gaskell
+1  A: 

WHat I have understand from your question, here is the code for you

$('#tableID tr:first ').append("<td class='TableHeading'>second</td>");    

 $('#tableID tr:not(:first)').each(function(){
       $(this).append("<td class='tdMiddleCells'>second</td>");

 });

Here you can loop through the table rows and then adding the column in each of the row. this will add column to last location, the first statement will add column as header and then remaining rows.

hope that will help.

Asim Sajjad
you can use prepend instead of append to add column at the first location , mean new column will be the first column as you have mentioned in your question
Asim Sajjad