I'm currently dealing with an external system that generates outdated code, however, I do have access to css and javascript. The specific issue at hand involves working with a table that displays each item on a separate row, sometimes resulting in up to 30 rows. My objective is to split these 'tr' elements into groups of 6 rows, with 5 items in each row.
The initial approach was to modify the style of each 'tr' element to display as table cells, thereby arranging them horizontally. Subsequently, I planned to assign a class to every 5th row and then insert closing and opening 'tbody' and 'table' tags after each 5th 'tr' with the designated class. This procedure was intended to create individual tables for every group of 5 'tr' elements, effectively forming rows of 5 items each.
While most of the setup works as expected, I encountered an issue with the .insertAfter method. The desired behavior was to insert '<\tbody><\table class='tableBreaker'><\tbody>' after every 5th 'tr', unfortunately, it produced unexpected results by reversing the order and outputting '<\table class="tableBreaker"><\tbody><\tbody>'.
I've tried searching for any relevant information regarding how jquery handles string manipulations within the .insertAfter function, but haven't found any clear solutions yet.
Table HTML:
<!-- Table HTML content goes here -->
CSS:
/* CSS styles go here */
jQuery:
// jQuery script goes here