views:

71

answers:

3

i have 2 main div:

    <div id="div1">
<div id="minidiv1">a</div>
<div id="minidiv2">b</div>
   </div>
   <div id="div2"></div>

I want move the minidiv1 into the div2 with jquery

how can i do?

+2  A: 

You can simply append it to the div2, and it will change its location in the DOM:

$('#minidiv1').appendTo('#div2'); 
// or
$('#div2').append('#minidiv1');

The difference of the above two lines is what is returned, appendTo returns the #minidiv element, append will return the #div2 element.

Use the one you find most useful if you want to make more actions (by chaining).

CMS
A: 
$('#minidiv1').appendTo('#div2');

or

$('#div2').append($('#minidiv1'));
Paul Creasey
A: 
$("#minidiv1").appendTo("#div2")
shylent