How to move an element into another element?
I would like to move one DIV element inside another. For example, I want to move this (including all children):
<div id="source">
...
</div>
into this:
<div id="destination">
...
</div>
so that I have this:
<div id="destination">
<div id="source">
...
</div>
</div>
Answer:
You may want to use the
appendTo
function (which adds to the end of the element):$("#source").appendTo("#destination");
Alternatively you could use the
prependTo
function (which adds to the beginning of the element):$("#source").prependTo("#destination");
http://stackoverflow.com/questions/1279957/how-to-move-an-element-into-another-element
COMMENTS