I have the following HTML structure: <div id="new-msgs"> <div class="msg">...</div> <div class="msg">...</div> </div>
I have the following code: $('#new-msgs') .appendTo('#prev-msgs') .wrap('<div id="p'+pCurrent+'"></div>'); I want everything inside #new-msgs to be appended to #prev-msgs, and not #new-msgs as well. Using a selector of "#new-msgs *" loses the hierarchical structure that I want to maintain (div.msg has children). Also using .html() on #new-msgs and then appending +wrapping results in multiple wraps. What's the best way to get the contents of a container and append them somewhere else?