How to use javascript to move a DIV into another DIV?

Hi there, does anyone know how to use javascript to move (move, not copy) the whole part of <div id="me"> as below

<div id="me">
  <!-- Part A: something else -->
</div>

into

<div class="this_target">
  <!-- Part B: something -->
</div>

,so that the result will be:

<div class="this_target">
 <div id="me">
   <!-- Part A: something else -->
 </div>
 <!-- Part B: something -->
</div>

Great if you have any idea! Thanks~

You need use append() method for this.

it would be like target.append(movingElement)

You can use jQuery method also which is very similar.
https://api.jquery.com/append/

1 Like

Hi, thanks a lot for the hint~

Gonna do it this way:
$("#me").detach().prependTo(".this_target");