-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrag.html
55 lines (52 loc) · 1.36 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery.js"></script>
</head>
<body>
<div id="container">
</div>
<script>
$(function () {
$("#container").on("dragstart dragend dragexit drop", function (e) {
console.info(e);
e.preventDefault();
});
$("#container").on("drop", function (e) {
console.info(e);
e.stopPropagation();
e.preventDefault();
var files = e.originalEvent.dataTransfer.files;
if(files && files.length > 0){
for(var i in files){
console.info(files[i]);
}
}
});
$("#container").on("dragleave", function (e) {
//e.preventDefault();å
$(this).css("border", "1px solid #0f0");
$(this).text(e.type);
// $(this).css("border", "none");
});
$("#container").on("dragover", function (e) {
e.preventDefault();
$(this).css("border", "1px solid #f00");
});
$("#container").on("dragenter", function (e) {
e.preventDefault();
$(this).text(e.type);
});
})
</script>
<style>
#container {
width: 200px;
height: 200px;
background: #eee;
}
</style>
</body>
</html>