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?
thank
$('.compareWrapper').append(htmlStr)
source to share
foo.appendTo(bar)
Take foo
and add it to bar
.
foo.append(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();
$clone.appendTo('wrapper');
$('wrapper').append($clone);
source to share