Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the table below that had a list of values in a row the problem is that i want to make it so that there's only 5 cells in a row i'm not really sure how to go about it do i have to use CSS to achieve it or a script any help would be greatly appreciated thanks!

What I have tried:

Here is my JSFiddle[^]
Posted
Updated 14-Jun-18 19:49pm

1 solution

You can start a new table row every time the index becomes a multiple of 5:

JavaScript
$.each(obj2[key3], function(index) {
  if(index % 5 == 0 && index > 0){
    bodyString += ('</tr><tr>');
  }
  bodyString += ('<td>' + obj2[key3][index] + '</td>');
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900