Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将div内的内容克隆到其他div_Javascript_Jquery_Html - Fatal编程技术网

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

Javascript 如何将div内的内容克隆到其他div,javascript,jquery,html,Javascript,Jquery,Html,如何在其他div container2中显示用户更新的divcontainer1的内容 <div id="container1"> <div id="slide1"> Content here include input box, select dropdown, normal text </div> <div id="slide2"> Editable Table </div> <div id="slide

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

 <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());
如果要替换:

$("#container2").empty().append($("#container1").clone().children());
使用jquery:

$("#container2").html($("#container1").html());
$function{ $click.clickfunction{ $container2.追加$container1.clone; }; }; 这里的内容包括输入框、选择下拉框、普通文本 可编辑表 可编辑图像 克隆它 用这个
$container2.追加$container1.html

使用克隆来完成。我真的很想知道为什么你们用html5画布和CSS来标记这个问题。不要垃圾邮件标记…@suchit kumar using clone正在返回空输入框,它没有将更新的数据包含到clones@A.Wolff我不得不在我的设计中使用画布和一些样式,这并不是为了垃圾邮件,我认为上述问题可能有任何解决方案。这将导致无效的HTML标记,因为IDs@A.Wolff我以为“展开”可以解决这个问题,但显然不行!首先,如果OP计划克隆它们,则不应使用它们True,但随后他克隆的是内容而不是divthemselves@RGraham感谢您的快速响应,但是当我尝试替换/克隆画布图像以及一些背景图像时,克隆/替换/修改的画布不会保留以前所做的更改。与普通文本不同