Drag & Drop
Drop Example
Code Only (Without ACF Integration)
HTML
<h2>Drag and Drop</h2> <p>Drag the image back and forth between elements.</p> <div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"> <img src="2.jpg" draggable="true" ondragstart="drag(event)" id="drag1" width="100%" height="auto"> </div> <div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div> <div id="div3" ondrop="drop(event)" ondragover="allowDrop(event)"></div> <div id="div4" ondrop="drop(event)" ondragover="allowDrop(event)"></div> <div id="div5" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
CSS
#div1, #div2, #div3, #div4, #div5 { float: left; width: 100px; height: 100px; margin: 10px; padding: 10px; border: 1px solid black; }
JAVA
function allowDrop(ev) { console.log("allowDrop"); ev.preventDefault(); } function drag(ev) { console.log("Drag"); console.log(ev.target.id); ev.dataTransfer.setData("text", ev.target.id); } function drop(ev) { console.log("Drop"); console.log(ev.target.id); ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementById(data)); }