~~~~ var list = document.getElementById('test-list') var slist = list.children; slist = Array.prototype.slice.call(slist).sort(function(a, b){ return a.innerHTML > b.innerHTML ? 1 : -1 ; }) slist.forEach(function(el){ list.appendChild(el); })
这个用的真巧妙,点赞
Sign in to make a reply
左转是绿灯
~~~~ var list = document.getElementById('test-list') var slist = list.children; slist = Array.prototype.slice.call(slist).sort(function(a, b){ return a.innerHTML > b.innerHTML ? 1 : -1 ; }) slist.forEach(function(el){ list.appendChild(el); })