Javascript 拖放交换完整对象而不仅仅是innertext

Javascript 拖放交换完整对象而不仅仅是innertext,javascript,jquery,html,drag-and-drop,Javascript,Jquery,Html,Drag And Drop,我有下面的代码,它在基于DND的情况下将一个divs innerHTML替换为其他divs innerHTML dragSrcEl = //This is the var that is assigned to the object that is being dragged, appears outside of this code below. dragSrcEl.innerHTML = this.innerHTML; this.innerHTML = e.dataTransfer.get

我有下面的代码,它在基于DND的情况下将一个divs innerHTML替换为其他divs innerHTML

dragSrcEl = //This is the var that is assigned to the object that is being dragged, appears outside of this code below.

dragSrcEl.innerHTML = this.innerHTML;
this.innerHTML = e.dataTransfer.getData('text/html');
如果我想让它改变一切,即整个容器、所有的rel、属性、类名、id、数据属性e.t.c,我该怎么办

我无法在dom中对其重新排序,因为动态方式会将其中的每一个拖放到


非常感谢

这将执行以下操作:

$(dargSrcEl).replaceWith(this);

.empty()用于容器中的项目。这样做,merly会将一个div添加到另一个div中。我认为这正是你想要的。我已经用另一个猜测编辑了我的答案,你可能在寻找什么。如果不是这样的话,我想你应该试着在你的问题中更清楚地知道你想做什么。