javascript - End table and start new after so many rows -


i have dynamic table outputted via cold fusion. table created fine, 1 of things i'm doing using javascript grab table's outerhtml , assign hidden elements value. catch hidden elements value needs have tables max of 20 rows each, , total original table can variable. need read table's outerhtml javascript variable , loop on contents , end table after 20 rows, create new table , continue adding remaining rows new table. suggestions?

so have coldfusion on server outputting table many rows , want use jquery on client chop big table many smaller tables, right? if so, here 1 way it:

example: jsfiddle

    var rows = $('#content tr');     var maxtablesize = 3;     while (rows.length) {         var newrows = rows.splice(0, maxtablesize);         $('<table><tbody>').append(newrows).appendto('#output');     }      $('#content').remove(); 

you need adapt whatever dom -- quick example showing works may need work differently consider posting jsfiddle if isn't want. note inefficient repeatedly append dom trigger lot of redraws (browser side). wanted keep example simple -- can read more how operate efficiently dom later.

the best thing modify server-side code spit out tables want them!


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -