如何将一个div的内容克隆到另一个div

2022-01-20 00:00:00 复制 clone dynamic jquery html

我想使用 jquery 克隆将选定 div 的内容复制到另一个 div.但我不想将它附加到任何地方

I want to copy the content of a selected div to another div with jquery clone. but I dont want to append it anywhere

我的意思是,当我们用 jquery 克隆一个 div 时(如果我错了,请纠正我)我们必须设置它的位置,它会动态创建一个显示的新分区.

what I mean is when we make a clone of a div with jquery (correct me if i am wrong) we have to set its position and it will dynamically create a new division which is displayed.

但我想获取选定的div的内容并将其复制到另一个预设的div

but I want to get the content of a selected div and copy it to another pre-set div

推荐答案

var a = $('#selector').html();
var b = $('#selector').html(a);

不确定我是否理解正确,但我认为这就是你的意思:)

not sure I understood you properly but I think thats what you meant :)

相关文章