【发布时间】:2012-04-11 22:22:12
【问题描述】:
我正在使用 jQuery 对 li 标签列表进行排序,我当前的代码是:
var arr = [];
$("ul li").each(function() {
arr.push($(this));
});
arr.sort(cmpFunction);
$("ul").find("li").remove();
$.each(arr, function(index, item){
console.log(item.html());
});
我在 console.log 中发现的 - 我正在丢失包含 li 标签的外部(带有我想要保留的 html5 数据属性)
.html() 是否还有另一个选项可以给我对象 li 标记
我在这里提供了一个我需要的简单示例:http://jsbin.com/esalas/5
【问题讨论】:
-
这不只是这个问题的重复:stackoverflow.com/questions/2419749/… ?
标签: javascript jquery