-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrag.html
32 lines (32 loc) · 815 Bytes
/
drag.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
<head>
<style>
.container{
width:350px;
height:150px;
padding:10px;
border:1px solid #aaaaaa;
}
</style>
<script>
function allowDrop(ev){
ev.preventDefault();
}
function drag(ev){
ev.dataTransfer.setData("text/html",ev.target.id);
}
function drop(ev){
ev.preventDefault();
var data=ev.dataTransfer.getData("text/html");
ev.target.appendChild(document.getElementById(data));
}
</script>
</head>
<body>
<p>Drag vvit logo into the rectangle</p>
<div id="div1" class="container" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<br>
<img id="drag1" src="vvit.png" alt="vvit.logo" draggable="true" ondragstart="drag(event)"/>
</body>
</html>