我有2个项目(" attrac")和2个放置区域(" sec")。我想把它放在一边。将项目拖放到放置区域,但我不希望从拖动列表中删除项目,因此我可以反复拖动它们
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var attracID = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(attracID));
}

<div id="sec1" ondrop="drop(event)" ondragover="allowDrop(event)" style="border: 2px solid red">
<h1>Shopping Cart</h1>
<ul></ul>
</div>
<div id="sec2" ondrop="drop(event)" ondragover="allowDrop(event)" style="border: 2px solid yellow">
<h1>Shopping Cart</h1>
<ul></ul>
</div>
<div>
<div ondragstart="drag(event)" id="attrac1" draggable="true">
<p>iMac</p>
</div>
<div ondragstart="drag(event)" id="attrac2" draggable="true">
<p>iPhone</p>
</div>
</div>
&#13;