How can a HTML table with horizontal headers be converted into a table where each row contains a table with two columns?
The column on the left would contain the vertical headers, while the one on the right side would contain the relevant values.
This fiddle shows an example of the original table and the table that would be shown instead.
Having a look at this couple of tables, the intended behaviour would consist of turning the table with horizontal headers into one with vertical headers, but minding the fact that, if the first table had more than one row, the second table should also contain the same number of rows, but formed by tables with vertical headers in the first column, and the correspondent values in the second column.
Original table:
<table id="tableid">
<thead>
<tr>
<th>Name</th>
<th>Surname</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Smith</td>
<td>47</td>
</tr>
<tr>
<td>Bob</td>
<td>Jones</td>
<td>38</td>
</tr>
</tbody>
Targeted table:
<table id="tableid">
<tr>
<table>
<tr>
<th>Name</th>
<td>John</td>
</tr>
<tr>
<th>Surname</th>
<td>Smith</td></tr>
<tr>
<th>Age</th>
<td>47</td>
</tr>
</table>
</tr>
<tr>
<table>
<tr>
<th>Name</th>
<td>Bob</td>
</tr>
<tr>
<th>Surname</th>
<td>Jones</td></tr>
<tr>
<th>Age</th>
<td>38</td>
</tr>
</table>
</tr>
</table>