var box=$('#test-div ul'), newList=['Pascal','Lua','Ruby'], newListHtml, a,b,li; for(let i=0;i<newList.length;i++){ newListHtml+='<li><span>'+newList[i]+'</span></li>'; } box.append(newListHtml); li=box.find('li'); li.sort((x,y)=>{ a=$(x).text().toUpperCase(); b=$(y).text().toUpperCase(); if(a<b){ return -1; }else if(a==b){ return 0; }else{ return 1; } }); box.append(li);
Sign in to make a reply
断桥-过后