0
jquery에서 정렬을 구현하는 방법. 아래 예제에서 "Var List"는 html 코드를 가지고 있는데, 여기서 "#points"필드를 클릭하면 정렬을 구현해야합니다. 이것은 파이어 폭스에서는 잘 작동하지만 IE와 crome에서는 그렇지 않습니다. 귀하의 경우 list
에 몇 가지 대안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);
});