How to move an element into another element using jQuery


Use the jQuery .appendTo() Method

You can use the jQuery .appendTo() method to move an element into another element.

The selected element will be taken out completely from its old location in the DOM and inserted at the end of the target container. Let's try out the following example:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Move a Div Element into Another Div</title>
        padding: 20px;        
        background: #f0e68c;
        padding: 20px;
        margin: 30px 0;
        border: 1px solid #333;
<script src=""></script>
            $(this).hide(); // Hide move button
    <div id="target" class="box">
        <h1>Target Container</h1>
    <div class="content">
        <h1>Hello World.</h1>
        <p>Click the "Move" button to move this content block inside colored box.</p>
        <button type="button">Move</button>