Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You may want to use the <a href="http://api.jquery.com/appendTo/" rel="noreferrer"><code>appendTo</code></a> function (which adds to the end of the element):</p> <pre><code>$("#source").appendTo("#destination"); </code></pre> <p>Alternatively you could use the <a href="http://api.jquery.com/prependTo/" rel="noreferrer"><code>prependTo</code></a> function (which adds to the beginning of the element):</p> <pre><code>$("#source").prependTo("#destination"); </code></pre> <hr> <p>Example:</p> <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false"> <div class="snippet-code snippet-currently-hidden"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$("#appendTo").click(function() { $("#moveMeIntoMain").appendTo($("#main")); }); $("#prependTo").click(function() { $("#moveMeIntoMain").prependTo($("#main")); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>#main { border: 2px solid blue; min-height: 100px; } .moveMeIntoMain { border: 1px solid red; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div id="main"&gt;main&lt;/div&gt; &lt;div id="moveMeIntoMain" class="moveMeIntoMain"&gt;move me to main&lt;/div&gt; &lt;button id="appendTo"&gt;appendTo main&lt;/button&gt; &lt;button id="prependTo"&gt;prependTo main&lt;/button&gt;</code></pre> </div> </div> </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload