如何使用jquery重新排序列表

时间:2014-03-26 06:27:44

标签: php jquery html css

当我使用jquery在运行时删除块div。我想重新排序sno。

var ID = 0;
$('div.block').each(function() {
    ID++;
    alert(ID)
    $(this+'> table > tbody > tr > td > .sno').html(ID);
});


<div class="block">
   <table>
     <tr><td><span class="sno">1</span></td></tr> 
   </table>
</div>
<div class="block">
   <table>
     <tr><td><span class="sno">2</span></td></tr> 
   </table>
</div>....

1 个答案:

答案 0 :(得分:1)

删除后,请使用:

 $('div.block').each(function(index) {
    alert(index+1)
    $(this).find('.sno').html(index+1);
}); 
相关问题