Considering the following code:
<tbody>
<tr class="wsui-table-row-odd">
<td>IamaTextFieldBox</td>
<td class="im-label-required">Label required</td>
</tr>
<tr class="wsui-table-row-odd">
<td>IamaTextFieldBox2</td>
<td class="im-label-required">Label required2</td>
</tr>
<tr class="wsui-table-row-odd">
<td>IamaTextFieldBox3</td>
<td class="im-label-required">Label required3</td>
</tr>
</tbody>
The following script allows to create a new <tr class='tr00'> above each <tr class="wsui-table-row-odd"> and place the <td class="im-label-required"> in the newly created <tr>.
$(document).ready(function() {
$("tr.wsui-table-row-odd").parent().prepend("<tr class='tr00'>");
$(".tr00").append($("td.im-label-required"));
});
Problem is it's placing all 3 <td class="im-label-required"> in each of the 3 newly created <tr class='tr00'>.
I would need the script to place solely the related <td class="im-label-required"> in its related <tr class='tr00'> like so:
<tbody>
<tr class="tr00">
<td class="im-label-required">Label required</td>
</tr>
<tr class="wsui-table-row-odd">
<td>IamaTextFieldBox</td>
</tr>
<tr class="tr00">
<td class="im-label-required">Label required2</td>
</tr>
<tr class="wsui-table-row-odd">
<td>IamaTextFieldBox2</td>
</tr>
<tr class="tr00">
<td class="im-label-required">Label required3</td>
</tr>
<tr class="wsui-table-row-odd">
<td>IamaTextFieldBox3</td>
</tr>
</tbody>
It should display:
Label required
IamaTextFieldBox
Label required2
IamaTextFieldBox2
Label required3
IamaTextFieldBox3
Thank you for your help.
IamaTextFieldBox? Because the HTML above hasIamaTextFieldBo2,IamaTextFieldBox3etc... See my updated answer.