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
2009-09-19 10:41:07
+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
2009-09-19 11:15:52
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
2009-09-19 11:28:22