How do I transfer an element into another element?

Asked 2 years ago, Updated 2 years ago, 41 views

For example,

<div id="source">
...
</div>

Elements containing these contents

<div id="destination">
...
</div>

I want to move it in here

<div id="destination">
  <div id="source">
    ...
  </div>
</div>

Like this.

html javascript jquery

2022-09-21 18:47

1 Answers

You can use the appendTo or prependTo function. AppendTo is added to the end of the element The prependTo is added to the beginning of the element.

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

You can use it like this.


2022-09-21 18:47

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.