Javascript 获取动态更新自身的div的html内容

Javascript 获取动态更新自身的div的html内容,javascript,jquery,html,Javascript,Jquery,Html,我有一个功能,用户可以保存应用程序的状态,应用程序由许多可视元素组成。为此,我想存储workspace div的整个html字符串 <div id = "workspace"> <div id = "playground"> here is my all div where user drag n drop the component from left hand side </div></div> 现在x只给我写在html文档上的

我有一个功能,用户可以保存应用程序的状态,应用程序由许多可视元素组成。为此,我想存储workspace div的整个html字符串

 <div id = "workspace">
 <div id = "playground">
   here is my all div where user drag n drop the component from left hand side 
 </div></div>
现在x只给我写在html文档上的html代码,而不是用户拖放到操场时附加的另一个div

任何机构有任何更好的解决方案,自动保存和恢复到原始状态,请让我知道

谢谢

试试这个

var x = document.getElementById("playground").innerHTML;
alert (x);

将类似
.droppableThing
的类分配给所有droppables,然后使用


$(“#游乐场”).child(“.droppableThing”)

在HTML中,“游乐场”拼写为“playgraound”
$(“#游乐场”).html()
似乎有效。这可能是您的问题吗?

尝试使用.text而不是.html!也许这会起作用。这在javascript中也是一样的:/
var x = document.getElementById("playground").innerHTML;
alert (x);