JQuery stop add div delete

I am copying a div to another div using append. However, it removes the original. I tried to use a clone but it only seems to work with appendTo. But appendTo is breaking my layout so I need to use append with fine works.

I am wrong that the clone won't work with .append and is there any other way to stop the div from being removed?





source to share

3 answers


Take foo

and add it to bar



Take bar

and add it tofoo

Syntactically they are different. You have to think about which target and which target. So, having said that you can move forward in one of two ways:

var $clone = $('target').clone();


Both do the same.



Does not work?





I see no reason .clone()

not to work with .append()

. The code should be:



Is this what you tried? From the name of your variable, I am assuming that htmlStr

is a string and not a jQuery object.



All Articles