var arr = [] $('.main-content .thred_block .content .bottom_block .tab_news ul:first-child').html('') $('.main-content .thred_block .content .bottom_block .tab_news ul li').each(function () { arr.push({ cattitle: $(this).attr('cattitle'), newsurl: $(this).attr('newsurl'), title: $(this).attr('title'), date: $(this).attr('date'), times: new Date($(this).attr('time').replace(';', ':')).getTime() }) }) //console.log(JSON.parse(JSON.stringify(arr))) var arrCount = arr.length for (var i = 0; i <= arrCount; i++) { for (var j = arrCount - 1; j > i; j--) { if (arr[j].times > arr[j - 1].times) { var temp = arr[j]; arr[j] = arr[j - 1]; arr[j - 1] = temp; } } } var oneUlstr = '' for (var k = 0; k < 10; k++) { //if(arr[k].title.indexOf('【')!= -1 && arr[k].title.indexOf('】') != -1){ if (false) { oneUlstr += `
  • ` + arr[k].cattitle +arr[k].title.split('】')[1] + ` `+ arr[k].date + `
  • ` } else { oneUlstr += `
  • ` + arr[k].cattitle + arr[k].title + ` `+ arr[k].date + `
  • ` } } $('.main-content .thred_block .content .bottom_block .tab_news ul:first-child').append(oneUlstr) //console.log(arr)