How to reverse the ordering of list items in an unordered list

前端 未结 8 1084
独厮守ぢ
独厮守ぢ 2020-12-29 17:06

Let\'s say I have an unordered list, like this:

  • Bald Eagle
  • Falcon
  • Condor<
8条回答
  •  臣服心动
    2020-12-29 17:27

    const list = document.querySelector("ul");
    Array.from(list.children).reverse().forEach(element =>list.appendChild(element));

提交回复
热议问题