Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding column on all row using jquery

Tags:

jquery

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

like image 683
kratz Avatar asked Sep 19 '09 10:09

kratz


1 Answers

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.

like image 107
Asim Sajjad Avatar answered Sep 22 '22 23:09

Asim Sajjad