I have a list of elements (X in the following examples) displayed either in a row or in a column of an HTML table.
In the HTML code point of view, I have either (horizontal display):
<table id="myTable">
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
...
</tr>
</table>
or (vertical display):
<table id="myTable">
<tr>
<td>A</td>
</tr>
<tr>
<td>B</td>
</tr>
<tr>
<td>C</td>
</tr>
...
</table>
This HTML code is generated by the JSF component (called <h:selectManyCheckboxes/>), and thus, I do not control this HTML code.
However, I want to display a list of items in 2 columns. In other words, the HTML code of my table will be something like this:
<table id="myTable">
<tr>
<td>A</td>
<td>B</td>
</tr>
<tr>
<td>C</td>
<td>D</td>
</tr>
...
</table>
How to do it using jQuery?
Thanks in advance for your help.
ps: If you need to know, X is actually the input and label, i.e.:
<td><input .../><label .../></td>
source
share