0

I am using the following code to drag images into an area of the screen. I want to know, is there a code that I can use to send the image back to its original location, or at least back to its original div. I need to do this, because after a certain time (lets just say 100s) I need a particular image to go back. So lets say I drag both images into the area, after 100s I want the first image back to its original location

<!DOCTYPE HTML>
<html>
<head>
<script>
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));
}
</script>
</head>
<body>
   <div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
   <img id="drag1" src="img_logo.gif" draggable="true" ondragstart="drag(event)" width="336" height="69">
   <img id="drag2" src="img_logo2.gif" draggable="true" ondragstart="drag(event)" width="336" height="69">
</body>
</html>
4

0 回答 0