Discuss / JavaScript / 原来如此

原来如此

Topic source

困了

#1 Created at ... [Delete] [Delete and Lock User]

var list=document.getElementById('test-list');

var arr=Array.from(list.children).sort((x,y)=>{return x.innerText>y.innerText?1:-1});

for(var i=0;i<arr.length;i++){

console.log(arr[i].innerText);

list.appendChild(arr[i]);

}


  • 1

Reply