Moving a DIV element to bottom of parent (as last child)

泪湿孤枕 提交于 2019-12-04 01:47:38

Here's some plain javascript to do it, assuming the div has a valid parent:

var d = document.getElementById('foo0');
d.parentNode.appendChild(d);

Essentially you get the node, then append it to its parent. appendChild, if the node is already part of the DOM, will move the node from its current position to the new position in the DOM.

wrap your divs with a parent div:

    var parentElement =  document.querySelector("#yourParentDiv");
    parentElement.appendChild(parentElement.firstElementChild);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!