如何将一个div的内容克隆到另一个div [英] how to clone content of a div to another div

查看:78
本文介绍了如何将一个div的内容克隆到另一个div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 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 :)

这篇关于如何将一个div的内容克隆到另一个div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆