18
我在DOM中有一个元素#superWidget,它非常具有交互性。它使用jQuery UI可排序,可拖动和其他一些插件。如何移动DOM中的元素?
<div id="wrapperA"></div>
<div id="wrapperB">
<div id="superWidget"></div>
</div>
我想更改#superWidget在DOM中的位置。我想从#wrapperB中删除它并将它放在#wrapperA中。
<div id="wrapperA">
<div id="superWidget"></div>
</div>
<div id="wrapperB"></div>
我曾尝试以下...
var copy = $("#superWidget").clone(true, true);
$("#superWidget").remove();
$("#wrapperA").append(copy);
......然而,这打破了很多的插件。
我不想重新绑定所有东西。有一个更好的方法吗? (我注意到,jQuery UI的排序在某种程度上能够在DOM中移动元素而不会破坏任何交互......一定有办法。)
感谢(提前)对你的帮助