1
我根據數據屬性值縮短了div。我現有的代碼在Firefox上運行良好,但它不適用於Chrome瀏覽器。Jquery排序功能在Chrome瀏覽器上不起作用
這裏是我的代碼:
$('select#shorting-job').change(function(e) {
var $list = $('.adsence-right');
var $productList = $('div.show-jobs-in-right',$list);
$productList.sort(function(a, b){
var keyA = $(a).attr("data-salary");
var keyB = $(b).attr("data-salary");
if($('#shorting-job').val()=='Salary'){
return false;
}else if($('#shorting-job').val()=='asc'){
return (parseInt(keyA) > parseInt(keyB)) ? 1 : 0;
} else {
return (parseInt(keyA) < parseInt(keyB)) ? 1 : 0;
}
});
$.each($productList, function(index, row){
$list.append(row);
});
e.preventDefault();
});