Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
HTML Drag and Drop Example
SUBMITTED BY:
kozma01
DATE:
Aug. 24, 2017, 1:54 p.m.
FORMAT:
Text only
SIZE:
595 Bytes
Raw
Download
Tweet
HITS:
5430
Go to comments
Report
Example
<!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">
</body>
</html>
Try it Yourself ยป
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus