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

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

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

  • Bald Eagle
  • Falcon
  • Condor<
8条回答
  •  忘掉有多难
    2020-12-29 17:32

    Manipulating the birdList doesn't re-order the elements because birdList is just a collection - a NodeList - which is independent of the DOM itself.

    You actually need to get a reference to the

      element and then use a combination of removeChild(...) and appendChild(...) - maybe insertBefore().

提交回复
热议问题