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>
没有评论:
发表评论