I am trying to drag and drop some items. I can drag a div over to the drop zone div, and it works fine. However, when i drag another div, i can actually drop it inside the previously dropped div. I do not want this. I want the drop zone to be the only place that can accept a dropped div.
<div class='container-fluid'>
<div class='row'>
<div class='col-sm-12' style='padding:0px;'>
<div class='col-sm-6'>
<div class='row'>
<div class='col-sm-2 drag-example' id='drag-1'
draggable='true' ondragstart='drag(event)'></div>
<div class='col-sm-2 drag-example' id='drag-2'
draggable='true' ondragstart='drag(event)'></div>
<div class='col-sm-2 drag-example' id='drag-3'
draggable='true' ondragstart='drag(event)'></div>
</div>
</div>
<div class='col-sm-6'>
<div class='row'>
<div class='col-sm-10 drop-example'
ondrop='drop(event)' ondragover='allowDrop(event)'
id='drop-div'></div>
</div>
</div>
</div>
</div>
</div>
function allowDrop(ev){
ev.preventDefault();
}
function drag(ev){
ev.dataTransfer.setData('text', ev.target.id);
}
function drop(ev){
ev.preventDefault();
var data = ev.dataTransfer.getData('text');
ev.target.appendChild(document.getElementById(data).cloneNode(true));
}