Discuss / JavaScript / 大家答案都很妙

大家答案都很妙

Topic source

L0standfound

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

var list = document.getElementById('test-list'); for (var i = 0; i < list.children.length - 1; i++ ) { for (var j = i + 1; j < list.children.length; j++ ) { if (list.children[i].innerText > list.children[j].innerText) { list.insertBefore(list.children[j], list.children[i]); } } }


  • 1

Reply