本文介绍了jQuery删除元素并重新编号其余元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人在我的代码中看到这个缺陷,因为这个让我感到难过!
Does anyone see the flaw in my code here, because this one has me stumped!
function removeMLRow(rowNo) { $('#ml_organize li:eq(' + (rowNo - 1) + ')').remove(); $($('#ml_organize li:eq(' + (rowNo) + ')').get().reverse()).each(function() { var newID = 'li' + ($(this).index() - 1); $(this).attr('id',newID); }); }推荐答案
尼克,你几乎在那里!在newID中需要(+1)而不是(-1)。
Nick, you were ALMOST there! Needed to (+1) instead of (-1) in the newID.
function removeMLRow(rowNo) { $('#ml_organize li').eq(rowNo - 1).remove(); $('#ml_organize li').slice(rowNo - 1).each(function() { var newID = 'li' + ($(this).index() + 1); $(this).attr('id',newID); }); var item_positions = $('#ml_organize').sortable('toArray'); alert(item_positions); }感谢大家的帮助!
更多推荐
jQuery删除元素并重新编号其余元素
发布评论