在手机自适应的时候,经常遇到PC端的左右侧元素需更改代码顺序
I would like to move one DIV element after another. For example, I want to move this (including all children):
<div id="source">
...
</div>
affter the
<div id="destination">
...
</div>
Solution
If the div where you want to put your element has content inside,and you want the element to show after the main content:
$("#destination").append($("#source"));
If the div where you want to put your element has content inside, and you want to show the element before the main content:
$("#destination").prepend($("#source"));
If the div where you want to put your element is empty, or you want to replace it entirely:
$("#element").html('<div id="source">...</div>');
If you want to duplicate an element before any of the above:
$("#destination").append($("#source").clone());