0
I’m working with drag and drop, and accurate to detect with JS when the element is not released in the marked zone, that is, when I drag the element but release it and it returns to its place.
It is possible to do this?
HTML + Javascript
function allowDrop(ev){
ev.preventDefault();
}
function drag(ev){
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev){
ev.preventDefault();
var element = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(element));
}
<div id="drag1" draggable="true" ondragstart="drag(event)"></div>
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
Yes, include your code in the question
– Leandro Angelo
@Leandroangelo I put the simplified code to make it easy to understand.
– Diego Vieira