-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathH5-1.html
37 lines (33 loc) · 910 Bytes
/
H5-1.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
33
34
35
36
37
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>H5-1</title>
<style type="text/css">
#div1{width: 400px;
height: 300px;
padding: 10px;
border: 1px solid lime;
}
</style>
<script type="text/javascript">
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>
<p>请把图片拖放到矩形中</p>
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<br>
<img id="drag1" src="img/eg_planets.jpg" draggable="true" ondragstart="drag(event)" />
</body>
</html>