Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何更新jQueryUI可排序表行的排名_Jquery_Jquery Ui - Fatal编程技术网

如何更新jQueryUI可排序表行的排名

如何更新jQueryUI可排序表行的排名,jquery,jquery-ui,Jquery,Jquery Ui,当使用jQueryUISortable对行进行排序时,您能看一下并让我知道如何对可排序表重新编号(排序)吗 如你所见,我有 <table> <thead> <tr> <th>Elem 1</th> <th>Elem 2</th> <th>Rank</th> </tr>

当使用jQueryUISortable对行进行排序时,您能看一下并让我知道如何对可排序表重新编号(排序)吗

如你所见,我有

<table>
    <thead>
        <tr>
            <th>Elem 1</th>
            <th>Elem 2</th>
            <th>Rank</th>
        </tr>
    </thead>    
    <tbody>
        <tr class="border_bottom">
            <td>X</td>
            <td>Y</td>
            <td>1</td>
        </tr>
        <tr class="border_bottom">
            <td>X</td>
            <td>Y</td>
            <td>2</td>
        </tr>
        <tr class="border_bottom">
            <td>X</td>
            <td>Y</td>
            <td>3</td>
        </tr>
        <tr class="border_bottom">
            <td>X</td>
            <td>Y</td>
            <td>4</td>
        </tr>
        <tr class="border_bottom">
            <td>X</td>
            <td>Y</td>
            <td>5</td>
        </tr>  
    </tbody>    
</table>
感谢

每当事件发生时,您都可以选择最后一个
并使用方法更新它们的文本,方法是返回其父
tr
相对于所有
元素的索引,使用方法如下:

$(“tbody”)。可排序({
更新:功能(e、ui){
$(“tr td:nth child(3)”).text(函数(){
返回$(this.parent().index(“tr”);
});
}
});
正文{
填充:30px;
}
桌子{
边界间距:塌陷;
边界间距:0;
}
运输署{
宽度:60px;
高度:25px;
文本对齐:居中;
}
tr.border_底部td{
底边:1pt纯色灰色;
背景:卡其色;
}

要素1
要素2
等级
X
Y
1.
X
Y
2.
X
Y
3.
X
Y
4.
X
Y
5.

谢谢TJ,这太完美了!
$( "tbody" ).sortable();