如何使用jQuery移动表行

时间:2013-02-04 10:24:35

标签: jquery html

我有这个代码

<tr class="parentRow">
    <td colspan="2">parentTd 01 </td>
</tr>

<tr class="childRow">
        <td> childTd 01 </td>

</tr>
<tr class="childRow">
        <td> childTd 02 </td>
</tr>


<tr class="parentRow">
    <td colspan="2">parentTd 02 </td>
</tr>

<tr class="childRow">
        <td> childTd 03 </td>
</tr>

<tr class="childRow">
        <td> childTd 04 </td>
</tr>

通过使用jQuery,我想创建一个只在 parentRow 中移动 childRow 的函数,以获得此代码设计的结果

<tr class="parentRow">
    <td colspan="2">parentTd 01 </td>
</tr>

<tr class="childRow">
        <td> childTd 02 </td>
</tr>
<tr class="childRow">
        <td> childTd 01 </td>
</tr>


<tr class="parentRow">
    <td colspan="2">parentTd 02 </td>
</tr>

<tr class="childRow">
        <td> childTd 04 </td>
</tr>

<tr class="childRow">
        <td> childTd 03 </td>
</tr>

有什么想法吗?对不起,如果你发现我的问题可能不够清楚!!

1 个答案:

答案 0 :(得分:0)

您可以尝试使用jquery ui .sortable()

LIVE DEMO