This is my implementation of WHATWG HTML5 Drag and Drop:
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.innerHTML+=" <p>"+document.getElementById(data).innerHTML+"</p>";
}
.div {
width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;
}
<div class="div" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<div class="div" ondrop="drop(event)" ondragover="allowDrop(event)">
<button id="drag1" draggable="true" ondragstart="drag(event)" width="336" height="69">Code</button>
<button id="drag2" draggable="true" ondragstart="drag(event)" width="336" height="69">Code</button>
</div>
It works fine in Google Chrome, but not in iOS or Android. I have read other topics about this but most of them suggest using jQuery or a JavaScript plugin.
Is it possible to make the HTML drag and drop implementation work on iOS and Android (mobile devices)?