javascript - 如何将div内的内容克隆到其他div

标签 javascript jquery html

如何在其他div(container2)中显示用户更新的div(container1)的内容

 <div id="container1">
   <div id="slide1"> Content here include input box, select dropdown, normal text </div>
   <div id="slide2"> Editable Table </div> 
   <div id="slide3"> Editable images </div>

   //Each slide will be hidden after it is updated
</div>

<div id="container2">
//Basically this is editable summary of all the slides
//But by using clone, only empty text box/dropdowns are displayed
//How to display the contents of updated slide1, slide2 and slide3 so that it can be editable like in previous container1 (replicating the container1)

</div>

最佳答案

如果您想附加:

$("#container2").append($("#container1").clone().children());

Demo

如果你想替换:

$("#container2").empty().append($("#container1").clone().children());

关于javascript - 如何将div内的内容克隆到其他div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28236705/

相关文章:

javascript - Typescript 中的类型 'getWeek' 上不存在属性 'Date'

javascript - 在 li 元素中选择嵌套的 div

javascript - 如何在 gridster 中的拖动停止事件中获取新的 col 和 row

javascript - 如何使用 jQuery 将 2 个 td 合并到一个 td 中?

javascript - 使用 Node js 上传文件的最佳方法

javascript - Firebase 基本 promise 返回

javascript - 遍历对象获取键和所有父键

jQuery ,未捕获的 TypeError : $(. ..).autoNumeric 不是函数

javascript - UI 开发 - JavaScript 与 Ajax

java - 提取表标题,然后添加到表中保存的所有记录的数组列表