Skip to main content
2 of 4
edited body
shadowbudz
  • 241
  • 1
  • 6
  • 17

How to move element to another element in Jquery

Hi i would like to move this element into another element. Sample

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

into this

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

so i have something like this

<div id="destination"> <div id="me-first"> <div id="source"> ... </div> <div id="last-here"> </div> </div>

Here is my code

jQuery(document).ready(function (){ jQuery("#destination") .prependTo("#source"); });

My problem is it will only transfer in the first place before me-first div. How do i put it in the middle of the me-first div and last-here div? Thanks

Here is the wrong placement after i ran my code.

<div id="destination"> <div id="source"> ... </div> <div id="me-first"> <div id="last-here"> </div> </div>

shadowbudz
  • 241
  • 1
  • 6
  • 17