jQuery appendTo()
move an element into another element
<!DOCTYPE html> <html lang="en"> <head> <title>jQuery Move a Div Element into Another Div</title> <style> .box{/* w w w. ja v a 2s.c o m*/ padding: 20px; background: #f0e68c; } .content{ padding: 20px; margin: 30px 0; border: 1px solid #333; } </style> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $(".content").appendTo("#target"); $(this).hide(); }); }); </script> </head> <body> <div id="target" class="box"> <h1>Target Container</h1> </div> <div class="content"> <h1>Hello World.</h1> <p>Click the "Move" button to move this content.</p> <button type="button">Move</button> </div> </body> </html>