2014-02-14 45 views
1

我有一个tablesorter表。 所以,如果我排序表,行号不会更新。它是固定的...Tablesorter:排序后更新行号

$("#tablesorter-demo tr").click(function() { 
    $('#tablesorter-demo tr').not(this).removeClass('hilite'); 
    $(this).toggleClass('hilite'); 
    var i = $("#tablesorter-demo tr").index(this); 
    $("#codefmenims_id").val($("#td_idfmenims" + i + "").text()); 
    $("#groupe1").val($("#td_gpefme" + i + "").text()); 
    $("#groupe1s").val($("#td_gpenims" + i + "").text()); 
}); 

有人能告诉我如何我可以更新我的表的行号,如果我排序表?

+0

可能与[此问题]相关(http://stackoverflow.com/questions/18763027/jquery-tablesorter-index-column-insert)〜参见[本演示](http://jsfiddle.net/Mottie/ 4mVfu/1162 /) – Mottie

回答

0
$("#tablesorter-demo tr").each(function(key) { 
    $(this).children('td').eq(0).text(key+1); 
}); 

请添加jsfiddle,以便发布更好的解决方案。

+0

好吧,你可以在这里看到它http://jsfiddle.net/9hHx5/5/ ..例如:所以如果你点击第1行,你会得到输入信息在这一行..如果你排序当点击标题时(例如Organisme),你点击表格的第一行,在排序之前你已经获得了表格的信息 – user1814879