0 votes
1 view
in Web Technology by (22.4k points)

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>

1 Answer

0 votes
by (40.3k points)

If you want to use the appendTo function (which adds to the end of the element), try this:

$("#source").appendTo("#destination");

Otherwise, you can use the prependTo function (which adds to the beginning of the element) like this:

$("#source").prependTo("#destination");

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...