I have an HTML table to which I would like to add or remove rows dynamically using a select box with some basic javascript.
I do not add separate lines, but a group of identical lines at the same time. For example, if I already had one set and then added another, the result would look like this:
<tr>
<th colspan="2">Item 1</th>
</tr>
<tr>
<th>Title</th>
<td>X</td>
</tr>
<tr>
<th>Description</th>
<td>Y</td>
</tr>
<tr>
<th colspan="2">Item 2</th>
</tr>
<tr>
<th>Title</th>
<td>A</td>
</tr>
<tr>
<th>Description</th>
<td>B</td>
</tr>
To add lines, I use the jQuery cloning method, so I need some kind of container element to get around a group of lines, however everything I tried (span, div, etc.) led to invalid HTML and did not work correctly.
The only way I could get it to work is to have each set as a separate table, but that is not the effect I want.
-, , ?