Dviding HTML table into multiple table JQuery?

To break the table and only have the first 3 columns.

To break the table and only have the first 3 columns: newT = jQuery(''); jQuery('. PrintTable table:lt(3)'). Each( function(i,el){ td = jQuery(''); td.

Append(jQuery(el).clone()); newT. Append(td); }); jQuery('. PrintTable').

Html(newT); If you want to keep the first column as a header for further breaks use the :first selector and add it to an intersection of the columns. JQuery('. PrintTable :gt(3):lt(6)') and you’ll get the first column and those between index 3 and 6.

You can actually merge the 2 so you only have to change the 2 indices to create the correct tables. This is the code snipped you’ll need. NewT = jQuery(''); jQuery('.

PrintTable table:first'). Add('. PrintTable table:gt(0):lt(3)').

Each( function(i,el){ td = jQuery(''); td. Append(jQuery(el).clone()); newT. Append(td); }); jQuery('.

PrintTable'). Html(newT); Exlanation of code: newT will hold a new tr element we will add the new tables content to. We will replace the old top tr element with this one.

We then select all the sub-tables via . PrintTable table, get the first header column with :first and add further columns selected with :gt(index) and :lt(index) where we pass an index to use. Gt = greater than, lt = lower than.

We now have all columns we want to use, so we use the each() function to add each element to the prepared td. Afterwards we can swap the old td with the new one to replace the old table with the new one. What you really want to do though, to make it less obscure table code, improve readability and syntax as well as thus printablility and stylablility is the following: Structure it in one table, as it is just one table of data.

Use the tags for headers in non tags. Type Of Transaction 2006 2007 Name Andi tom Age 25 26.

Sry for all the edits, but it's finished now. :P Tested, works. – Kissaki Jan 11 at 19:42 Wow that was awesome.

Now lets say I have 8 columns, now I will have three tables first with 3 columns, second table with three columns and 3rd table with two columns. All the table should have same header. That is what I am trying to find out.

– Nrusingha Jan 11 at 20:38 Yeah, that works with the code above. To iterate over the number of rows you can use .size() to get the number of rows after selecting them. Api.jquery.Com/size Then you can iterate over the columns by changing the indices of the selectors.

– Kissaki Jan 11 at 20:42 I did not understand what exactly you are doing in function(i,el){ td = jQuery(''); td. Append(jQuery(el).clone()); newT. Append(td); What values are getting passed in function(i,el).

– Nrusingha Jan 11 at 20:47 The function is an anonymous function passed to each(), so it is called for each element in the list (each sub-table). A td element is created for the sub-table to be added. Then a clone of el, the which is the sub-table, is added to the td tag (clone is necessary as el is a function parameter var/ref, which will be re-used in the function).

Then the td element/tag is added to the newTable. – Kissaki Jan 11 at 20:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions