Copying DOM objects as a new object with JQUERY

0

I want to insert the copy of a content into two divs I made a clone and then wanted to make an append. Since append moves the contents of the last insert in the DOM.

var copia = $('div#conteudo').children().clone(true);

$('div#vazia1').append(copia);
$('div#vazia2').append(copia);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="conteudo">
    <p> meu conteudo </p>
</div>

<div id="vazia1">
    <p> vazia 1 </p>
</div>

<div id="vazia2">
    <p> vazia 2 </p>
</div>

The problem seems to me to be the issue of copying. A similar issue has already been addressed in How to create a copy of an object in JavaScript? but the answer still remains vague, perhaps complicated.

How to make a simple copy and not make a passage by reference? I show the problem at link

I want to make a copy of elements of the DOM and modify the original without the copy receiving the changes. I want this copy to be a new element independent of the first. Is this possible?

    
asked by anonymous 31.10.2015 / 04:13

0 answers