Answers for "html image drag and drop"

0

html no drag image

<img draggable="false" src="http://www.ourkanpur.com/images/logo.png">
Posted by: Guest on June-01-2021
2

drag and drop html

<!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="box" ondrop="drop(event)"
   ondragover="allowDrop(event)"
   style="border:1px solid black; 
   width:200px; height:200px"></div>

   <img id="image" src="sample.jpg" draggable="true"
   ondragstart="drag(event)" width="150" height="50" alt="" />

</body>
</html>
Posted by: Guest on June-09-2021
0

drag and drop html

function drag(ev) {
    ev.dataTransfer.setData("text", ev.target.id);
}
Posted by: Guest on June-09-2021

Browse Popular Code Answers by Language