0
如何在jQuery中實現排序。在下面的例子「Var列表」具有HTML代碼,我需要實施排序點擊一個提交「#點」。這在Firefox中工作正常,但不在IE和Crome中。請建議一些替代排序在jquery
$("#points").click(function() {
var list = $('#categoryDetailedView>li');
var sortcol = ".points";
if ($(this).attr("data-sort") == "desc") {
list.sort(function (a, b) {
alert($(sortcol, a).html());
return parseInt($(sortcol, a).html(), 10) > parseInt($('.points', b).html(), 10);
});
$(this).attr("data-sort", "asc");
} else {
list.sort(function (a, b) {
return parseInt($(sortcol, a).html(), 10) < parseInt($('.points', b).html(), 10);
});
$(this).attr("data-sort", "desc");
}
$('#categoryDetailedView').html(list);
});