0

帮助,这是我的代码:

<script>
$(document).ready(function() {
// Get your list items
var items = $('ul.categories > li');

// The new index order for each item, first item is always numbered "0"
var order = [4,2,3,0,1];

// Map the existing items to their new positions        
var orderedItems = $.map(order, function(value) {
    return items.get(value);
});

// Clear the old list items and insert the newly ordered ones
$('ul.categories').empty().html(orderedItems);
});
</script>

这种重新排序适用于除 IE 之外的所有浏览器(它显示列表两次,所以我怀疑由于.empty()某种原因不起作用?

提前谢谢了。

4

1 回答 1

0

你不需要清空它

尝试

$('ul.categories').html(orderedItems);

于 2013-11-11T03:14:31.900 回答