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

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

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

  • Bald Eagle
  • Falcon
  • Condor<
8条回答
  •  时光说笑
    2020-12-29 17:41

    var birds = document.getElementById('birds');
    
    for(var i = 0, bll = birds.childNodes.length; i < bll; i++) {
      birds.insertBefore(birds.childNodes[i], birds.firstChild);
    }
    

提交回复
热议问题