2021年4月11日星期日

Drag and Drop box for an image in ruby on rails

Attached is my code and though it makes a box the image does not actually enter the box. What am I doing wrong?

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));  }
#div1 {    width: 350px;    height: 70px;    padding: 10px;    border: 1px solid #aaaaaa;  }
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div> <br>
https://stackoverflow.com/questions/67051824/drag-and-drop-box-for-an-image-in-ruby-on-rails April 12, 2021 at 10:04AM

没有评论:

发表评论